when I try to publish my unity games on google developer, I always have this error:
Failed to import. You have imported an APK or Android App Bundle that
can be debugged. For security reasons, you must disable debugging
before the applicable APK or Android App Bundle can be published on
Google Play. Learn more about APKs or Android Bundle Bundle packages
for which the Debug feature has been enabled.
You have imported an APK or an Android App Bundle with a signature in debug mode. You must sign it in output version mode. Learn more about the signature.
I think there are something in maintemplate.gradle to change:
this is my mainTemplate:
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
allprojects {
repositories {
flatDir {
dirs 'libs'
}
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
**DEPS**}
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
defaultConfig {
targetSdkVersion **TARGETSDKVERSION**
applicationId '**APPLICATIONID**'
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress '.unity3d', '.ress', '.resource', '.obb'
}
**SIGN**
buildTypes {
release {
// Set minifyEnabled to true if you want to run ProGuard on your project
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debbugable false
**SIGNCONFIG**
signingConfig signingConfigs.firstapp
}
}
}
Just make sure your settings are like this -
Related
today I tried to build my game for Android with Unity 2020.2.6f1 and it gave the error below;
UnityException: Error mainTemplate.gradle file is using the old
aaptOptions noCompress property definition which does not include
types defined by unityStreamingAssets constant.
I disabled the Android Resolvers Patch gradle and manifest files it didn't work.
I tried to edit the gradle manually with;
aaptOptions {
noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}
whatever I do when building the game Unity overrides the gradle, I checked the pre-post build process scripts in the project but none of the ones I check changes the gradle' aaptOptions.
The plugins I have in the project are;
Facebook
GameAnalytics
Adjust
mainTemplate.gradle:
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
}
}
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}
apply plugin: 'com.android.library'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.installreferrer:installreferrer:1.0'
**DEPS**
}
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
defaultConfig {
multiDexEnabled true
minSdkVersion 19
targetSdkVersion 29
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
}
dexOptions {
preDexLibraries false
javaMaxHeapSize "4g"
}
lintOptions {
abortOnError false
}
packagingOptions {
exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
}
aaptOptions {
noCompress '.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**
}
**SIGN**
buildTypes {
debug {
jniDebuggable true
}
release {
minifyEnabled false
**SIGNCONFIG**
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_8
}
}
Thanks in advance.
you should modify like this in the mainTemplate.gradle file :
aaptOptions {
noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}
For me what worked was unchecking the "Custom Gradle Template" option for the build inside Player Settings > Publishing Settings.
Edit: Okay it turns out that I can't replicate that anymore and I am not really sure what kind of wizardry allowed it to happen...
On the other hand, I found what caused the issue for me.
The problem was caused by one plugin I was using, since I was importing an old version of it and for some reason it kept importing gradle documents and other Android related stuff, which were deprecated.
I fixed it by importing everything from the plugin's Unity Package except the Android folder, all the Editor's gradles and gradle related stuff (I didn't import the Editor folder at all) and the Plugins folder.
Let's try this option. Work like champ.
Open file maingradle in Android folder and remove line have string "Proguard" then save file
Go to project setting => untick mainGradle and tick again mainGradle, untick gradle properties template and tick it again. Go to Asset option in top => find option force resolve and rebuild again.
Why I get these errors I try to release apk
I run "flutter build apk --release"
Execution failed for task ':app:lintVitalRelease'.
A problem occurred configuring root project 'android_intent'.
What went wrong: A problem occurred configuring root project 'android_intent'.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
android/app/build.gradle
def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
} }
def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") }
def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) {
flutterVersionCode = '1' }
def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) {
flutterVersionName = '1.0' }
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.deleviry"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
} }
flutter {
source '../..' }
dependencies {
implementation 'com.google.firebase:firebase-core:17.2.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" }
apply plugin: 'com.google.gms.google-services'
android/build.gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }
allprojects {
repositories {
google()
jcenter()
} }
rootProject.buildDir = '../build' subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects {
project.evaluationDependsOn(':app') }
task clean(type: Delete) {
delete rootProject.buildDir }
Upgrading gradle build tools seems to break some lints.
To fix this you can:
If your error says debug/libs.jar, build --debug then --release.
If your error says profile/libs.jar, build --profile then --release.
from https://github.com/flutter/flutter/issues/58247#issuecomment-636500680
If the above doesn't work you can disable the check.
Add checkReleaseBuilds false in lintOptions in the android/app/build.gradle file.
android {
...
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false //<- add this line
}
}
If your error says debug/libs.jar, build --debug then --release:
flutter build apk --debug
flutter build apk --release
If your error says profile/libs.jar, build --profile then --release:
flutter build apk --profile
flutter build apk --release
Taken from here
If you're having this issue and you can't fix it with either fixes like me, you might be having different flavors. I had to run the run and run --release command for every flavor before I could build one without an error.
so
flutter run --flavor dev
... (do so for every flavor)
flutter run --flavor lastFlavor
then
flutter build apk --flavor dev (error)
... (do so for every flavor)
flutter build apk --flavor lastFlavor (SUCCESS!)
and from now on you can build every flavor without error :)
I've stuck to the latest Android Studio Gradle plugin from the 3.x series (3.6.4) paired with an up-to-date Gradle version (AS plugin 3.6.4 + Gradle 6.6 yields no error for me).
Edit: As of today July 13th 2021, Flutter 2.2.3 runs fine with Android Studio Gradle plugin version 4.2.2 and Gradle 6.8.3 (stable)
Not sure if this is the correct way, but I solved similar issue by adding these lines
release {
signingConfig signingConfigs.debug
shrinkResources false // Add this line
minifyEnabled false // Also add this line
}
in my case, this part of the code was absent in android/app/build.gradle so i added it and it worked.
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false
}
I have resolved this issue by adding classpath "com.android.tools.build:gradle:7.2.1" in android>build.gradle dependecies. It worked perfectly.
Note: my gradle wrapper version was https://services.gradle.org/distributions/gradle-7.4.2-all.zip in gradle-wrapper.properties
Basically this problem occurred some of dependencies uses latest gradle version and your project version is different.
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false //<- add this line
}
add this code will solve your problem
I have an issue in Android studio related to Facebook SDK and it's as below :
The build.gradle file (Project) looks like this :
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
jcenter {
url "http://jcenter.bintray.com/"
url 'https://maven.google.com'
}
}
}
The build.gradle file (Module:app) looks like this :
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.xxx.xxx"
minSdkVersion 15
targetSdkVersion 27
versionCode 5
versionName "1.4"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
debug {
//minifyEnabled true
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:27.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.facebook.android:account-kit-sdk:4.+'
compile 'com.google.android.gms:play-services-ads:11.0.1'
compile 'com.google.android.gms:play-services-auth:11.0.1'
compile 'com.google.android.gms:play-services-gcm:11.0.1'
}
Repositories are well added but i can't figure out the issue.
Many thanks.
I read the documentation but I could not make it. I am using Android Studio 2.0 Stable version.
This is my project level build.gradle file :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and this is app module level build.gradle file :
buildscript {
repositories {
mavenCentral() // or jcenter()
}
dependencies {
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.4.4'
}
}
apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.hugo'
dexcount {
format = "list"
includeClasses = false
includeFieldCount = true
includeTotalMethodCount = false
orderByMethodCount = false
verbose = false
maxTreeDepth = Integer.MAX_VALUE
teamCityIntegration = false
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "my_package_name"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0.0"
}
buildTypes {
debug {
debuggable true
minifyEnabled false
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
debuggable false
minifyEnabled false
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions{
exclude 'META-INF/maven/commons-io/commons-io/pom.xml'
exclude 'META-INF/maven/commons-io/commons-io/pom.properties'
}
}
ext {
supportLibVersion = '23.3.0'
googlePlayServicesVersion = '8.4.0'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:percent:${supportLibVersion}"
compile "com.android.support:cardview-v7:${supportLibVersion}"
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
// eventbus
compile 'org.greenrobot:eventbus:3.0.0'
// rate me dialog
compile 'com.github.hotchemi:android-rate:0.5.6'
// apache commons-io
compile group: 'commons-io', name: 'commons-io', version: '2.0.1'
}
this is giving error everytime :
Error:(11, 0) Dexcount plugin requires the Android plugin to be configured
what is the solution of this error ?
SOLUTION
I shifted the line of
"apply plugin: 'com.android.application'"
with
"apply plugin: 'com.getkeepsafe.dexcount'"
and it's worked
It is documented in Dex count's GitHub repo:
// make sure this line comes *after* you apply the Android plugin
apply plugin: 'com.getkeepsafe.dexcount'
So as you said, just make sure that the Android plugin is before the Dex count plugin.
apply plugin: 'com.android.application'
apply plugin: 'com.getkeepsafe.dexcount'
I'm trying to integrate twitter login in my application, however not able to succeed yet.
https://dev.twitter.com/twitter-kit/android/twitter-login
In the above link it asks us to install Twitter Core library
dependencies {
compile('com.twitter.sdk.android:twitter-core:1.3.1#aar') {
transitive = true;
}
}
However, this library isn't being downloaded. I always throws an error
Failed to resolve: com.twitter.sdk.android:twitter-core:1.3.1
What should i do?
I have just solved your problem using the next instructions:
Inside your build.gradle (general):
your build script must be like this:
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
2.Your build.gradle (app) must be like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.yourappname"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile('com.twitter.sdk.android:twitter:1.5.1#aar') {
transitive = true
}
}
If you have any question, try to take a look this link:
https://github.com/twitter/twitter-kit-android
It works for me! Hope it helps!