I am able to successfully test on my android device via "Build and Run" in Unity 5.3.5.
I am able to export the unity project to Android Studio.
However, when I run the android studio project, it gives me numerous errors.
The first was solved by adding the following to the .gradle file:
multiDexEnabled true
Now I have come across the problem of:
Error:Execution failed for task ':fishDiver:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/unity/purchasing/amazon/BuildConfig.class
My gradle file is as such:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.sink.fish"
minSdkVersion 9
targetSdkVersion 19
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':amazonAppStore')
compile project(':googleAIDL')
compile project(':googlePlay')
compile project(':common')
compile project(':unityadsrelease')
compile files('libs/unity-classes.jar')
}
Can anyone point me in the right direction?
I have not added anything extra, only the Unity Ads API, Unity IAP API, and the Unity Analytics API.
But other then that it is a pretty basic build and it is not working!
What I have tried:
gradle cleaning:
./gradlew clean
Deleting the build folders,
removing any added plugins for Android within Unity,
Rebuilding and cleaning from within Android Studio
random tweaks here and there
Related
I'm running the application in Android 5.1 device and it's running well after some time i have uninstalled the android studio and now i have installed Android Studio 3.0.1 and working on Elementary OS Loki and trying to run it on Android 8.0 device and when I start new app and run it then all goes well but the existing project is not running it gives error while running
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException:
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
And I have build.gradle file as below
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "za.co.neilson.alarm"
multiDexEnabled true
minSdkVersion 16
targetSdkVersion 26
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:26.0.0'
implementation files('lib/android-support-v7-appcompat.jar')
}
I have googled and tried other solutions like
multiDexEnabled true
And rebuild / clean project but it did not work
Since you are using compile 'com.android.support:appcompat-v7:26.0.0' there are no reasons to add the jar file (also pay attention since the aar contains the jar file but also the resources).
Remove this line:
implementation files('lib/android-support-v7-appcompat.jar')
and delete the lib/android-support-v7-appcompat.jar file
I have googled and tried other solutions like
multiDexEnabled true
It is completely useless in your case. Use it when your app and the libraries it references exceed 65,536 methods, not when you are adding twice the same classes.
Try to change your gradle version to 3.0.1 or 2.3.3. By changing to one of them it may work for you.
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
//or try classpath 'com.android.tools.build:gradle:2.3.3'
}
After this clean and rebuild the project.
Hope it helps you.
I have tried to put Facebook ads in my application, which is earlier works with Google Admob ads. But while adding this line in my gradle file makes errors. compile 'com.facebook.android:audience-network-sdk:4.+'. I have also tried with the specified versions. But same errors.
Main error is
can't resolve Symbol R
I also tried clean, rebuild and Sync Project with Gradle file. But no response.
I have updated my Google play services, and Google Respirotory.
Here is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 15
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.myapp.application"
minSdkVersion 15
targetSdkVersion 15
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':businessApp')
compile 'com.facebook.android:audience-network-sdk:4.+'
}
I can successfully build the gradle if I remove this line
compile 'com.facebook.android:audience-network-sdk:4.+'
There is no other errors in My app. If I need to change anything in Android studio to use Facebook Audience Network, or any other requirements?
After adding this dependency , sync your project and then click on Build-->Clean Project
I created my first Android app 2 years ago in Eclipse and now I have some time to improve it. I do not have Eclipse installed anymore, so I decided to import the project into Android Studio.
But now I am running into several problems:
Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller than version 14 declared in library [com.google.android.gms:play-services:10.2.0]
So in the build.gradle I changed it to 14. Then I got the next error
Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner.Underlined'.
So therefor I changed the compileSdkVersion and the targetSdkVersion to 25 (correct me if it's wrong). And I changed
compile 'com.android.support:support-v4:20.0.0'
into
compile 'com.android.support:support-v4:25.2.0'
Now I could build my project. But when I tried to run my app, after more then 5 minutes(!) I got the next error :
Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
So then I added
multiDexEnabled true
and
compile 'com.android.support:multidex:1.0.1'
and
android:name="android.support.multidex.MultiDexApplication"
to the manifest file.
My build.gradle now looks like this
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "<<myApplicationId>>"
minSdkVersion 14
targetSdkVersion 25
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:25.2.0'
compile 'com.google.android.gms:play-services:+'
compile files('libs/AppFireworks.jar')
compile files('libs/fcvtgzwtzuliivdcu.jar')
compile 'com.android.support:multidex:1.0.1'
}
But now I got the following pop-up and errors
Instant Run does not support deploying build variants with multidex enabled, to a target with API level 20 or below. To use Instant Run with a multidex enabled build variant, deploy to a target with API level 21 or higher.
Error:UNEXPECTED TOP-LEVEL ERROR:
Error:java.lang.OutOfMemoryError: GC overhead limit exceeded
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
What have I done wrong? Do I have to change the minSdkVersion to 21? I want to be able to run my app on Android 4.x. I could when I was developing in Eclipse. So far switching from Eclipse to Andriod Studio is going from bad to worse. :-(
you are compiling using compile 'com.google.android.gms:play-services:+'
play service is itself is a large library. You should not use + which implies all available version to compile
Rather use a specific version of play services or break down the library and use specific services like location,maps etc.
Also u can use dexOptions to increase ur memory usage during compilation
try changing your gradle file to:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "<<myApplicationId>>"
minSdkVersion 14
targetSdkVersion 25
multiDexEnabled true
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:25.2.0'
compile 'com.google.android.gms:play-services-maps:9.0.1'
compile 'com.google.android.gms:play-services-plus:9.0.1'
compile 'com.google.android.gms:play-services-location:9.0.1'
compile 'com.google.android.gms:play-services-games:9.0.1'
compile 'com.google.android.gms:play-services-gcm:9.0.1'
compile files('libs/AppFireworks.jar')
compile files('libs/fcvtgzwtzuliivdcu.jar')
compile 'com.android.support:multidex:1.0.1'
}
I have this error whenever i try to create an APK for the app.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/text/TextUtilsCompat.class
The app run in the android emulator , but when i try to build an apk i get this error.
i dont know what to change
here is the gradle code
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.companyname.gamename"
minSdkVersion 11
targetSdkVersion 23
multiDexEnabled true
ndk {
moduleName "player_shared"
}
}
sourceSets {
main {
jni.srcDirs = []
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:+'
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/support-v4-19.0.1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
}
I tryed to clean rebuild an run the prject but i still have the same problem,
I've read that it's depencdencies problem. but can't figure wich one to remove.
First, never use a plus dependency.
services:+'
Also don't compile all the Play Services, only setup ones you really need.
https://developers.google.com/android/guides/setup#split
Secondly, stop using jar files and go find the correct libraries using Maven Central (or the supporting documentation for those libraries) and use the other way to compile through Gradle.
Your jar files have overlapping classes and therefore you have errors
While you're at it...
Dagger 1 is being deprecated for Dagger 2
NineoldAndroids has stopped being maintained, so best to find some other way to use the code you need it for
Your support libraries need to match the compileSdk version
I imported a project into Android Studio from Eclipse. It was building successfully in Eclipse.
At the end of importing process I got this error:
Gradle project sync failed. Basic functionality will not work
In the Gradle console I get the following error:
Error:Failed to find: com.android.support:appcompat-v7:20.+
I have already installed google support repository as mentioned in other places.
This is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "21.0.0"
defaultConfig {
applicationId "com.entujn.demo"
minSdkVersion 10
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.txt'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:20.+'
compile files('libs/commons-lang3-3.3.2.jar')
}
local.properties:
sdk.dir=/home/pankaj/adt-bundle-linux-x86_64-20140702/sdk
SDK directory structure screenshot
Looks like the appcompat stuff is not present at the right place, how do I fix it ?
Looks like Android Studio uses another copy of SDK, which does not have Android Support repository installed. Please make sure it has all needed components installed.