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.
Related
I've just updated my flutter project packages to be null-safety compliant and now Android Studio wants me to update my project to use the latest version of Kotling Gradle Plugin. Can't see where to change this though. I have tried to change "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" into "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10" but this has no effect.
My build.grade-file looks like this:
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"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 31
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 "*********"
minSdkVersion 30
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
}
apply plugin: 'com.google.gms.google-services'
Build output:
BUILD FAILED in 8s
[!] Your project requires a newer version of the Kotlin Gradle plugin.
Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then update project/android/build.gradle:
ext.kotlin_version = '<latest-version>'
Exception: Gradle task assembleDebug failed with exit code 1
You need to change the kotlin version in your android root project, projectName/android/build.gradle, instead of projectName/android/app/build.gradle.
Change the version at ext.kotlin_version line:
buildscript {
ext.kotlin_version = '1.6.10' // Change here
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
UPDATE
The above solution will also works if your android part of the project is using java where the dependencies are using kotlin and you've encountered the following error:
Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: /home/user/.gradle/caches/transforms-3/36814238b86d8b6b6f9e4e1263bce879/transformed/jetified-kotlinx-coroutines-core-jvm-1.5.2.jar!/META-INF/kotlinx-coroutines-core.kotlin_module:
Module was compiled with an incompatible version of Kotlin.
The binary version of its metadata is 1.5.1, expected version is 1.1.15.
AndroidStudio or IntelliJ Idea will give hint in the project build.grade file if the kotlin is not the same with the installed kotlin in the IDE.
Update your Kotlin to the Latest version. You can see the latest version here
ext.kotlin_version = '1.6.10' //
You can see the latest version of Kotlin from the below link
https://kotlinlang.org/docs/gradle.html#plugin-and-versions
change build gradle to this :
classpath 'com.android.tools.build:gradle:4.1.0'
and gradle-wrapper to this :
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
I Update Flutter to 2.10.1
and I found All My Project Has Same Error
in app /build.gradl
you change to ext.kotlin_version = '1.6.10'
In my case, I don't use kotlin in my flutter project, but some of my dependencies use it (It was assets_audio_player for me), so I had to go to build.gradle for that dependency and update the kotlin version as other answers here:
ext.kotlin_version = '<latest-version>'
Note 1: you can open build.gradle for the library you want by opening the android module in Android Studio then go to Gradle Scripts from Project tab.
Note 2: you can know which library is causing the error by looking at:
Execution failed for task ':assets_audio_player:compileDebugKotlin'.
It could be more than one library, so after you change kotlin version the error will be changed.
You have to change the kotlin version in your android root, go to
projectName/android/build.gradle
buildscript {
ext.kotlin_version = '1.7.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
And change the gradle wrapper version to 6.7.1-all or higher in the gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
Also you can get the lattest version here
Change the build gradle version to 4.1.0 or higher in the project-level build.gradle file:
classpath 'com.android.tools.build:gradle:4.1.0'
Change the gradle wrapper version to 6.7-all or higher in the gradle-wrapper.properties file:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
Change the ext.kotlin_version to 1.6.10 or higher in the project level build.gradle file:
buildscript {
ext.kotlin_version = '1.6.10' // Change like this
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
1- First change ext.kotlin_version on projectName/android/build.gradle
buildscript {
ext.kotlin_version = '1.6.10'
}
2- Second change build gradle to this :
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
Maybe anyone else is stumbling across an issue I had after upgrading flutter:
If you use flutter together with aws_amplify you have to also upgrade amplify. This is a issue I had with the same error message.
You can reach the latest version from here.
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 -
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!
I am a complete noob with Gradle. I am writing an android application using Android Studio with a co-worker who is using Eclipse. we are sharing our files through git. It was created in eclipse without Gradle. My question is, is it possible to generate the gradle files for the project on my end without him having to export the project on his? I am trying to setup ActionBar Sherlock and its causing me all sorts of trouble I think the lack of a grable.build file might have something to do with it.
You can include abs in your project as a library.
Put a build.gradle in abs module:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+' // You can use also classpath 'com.android.tools.build:gradle:0.6.+' with gradle 1.8
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:18.0.0'
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1" //use your build version
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
Then in your project module add in build.gradle:
dependencies {
compile project(':libraries:actionbarsherlock') //Use your name
}
You have to setting also setting.gradle
include ':MyApplication'
include ':libraries:actionbarsherlock'
You can see this post:
http://gmariotti.blogspot.it/2013/06/quick-tips-convert-to-new-gradle-based.html
Otherwise, you can ignore the library folder and only use in your project module this script in build.gradle.
Gradle will download from maven the aar format.
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
}
All you need is a simple build.gradle file for your ActionBarSherlock project. Here's one I've created:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:13.0.0'
}
android {
buildToolsVersion "17.0"
compileSdkVersion 17
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}