Millennial Media SDK 6.4 integration in Android fails - java

I'm trying to integrate Millennial Media SDK 6.4 in my Android app, but it shows an error message below when I run the app on my phone.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/gcm/PendingCallback$1.class
At first, I run the sample code with latest SDK downloaded directly from Millennial Media site, and it worked perfectly on my device. Then I migrated the inline ad code into my app following the official integration guide and there were no any problems when compiling or cleaning the project until I attempted running it in my phone. Please see my build.gradle file below.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId '<My Application ID>'
minSdkVersion 16
targetSdkVersion 25
versionName '1.0'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
versionCode 5
versionNameSuffix '5'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding.enabled = true;
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:preference-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.firebase:firebase-jobdispatcher:0.6.0'
compile 'com.android.support:support-v4:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
compile project(':android-ad-sdk')
compile 'com.google.android.gms:play-services:10.2.4'
}
I have tried cleaning gradlew, updating the gradle version and restarting the project, but nothing works. I have also contacted Millennial Media support team a day ago, though no response has been heard yet.
Have anyone seen this problem or known how to fix. Please give me any advices that I will appreciate. Or do you use other ad network providers that could be better than Millennial Media?
Cheers.
Update 1:
I've tried commenting compile "com.google.android.gms:play-services:10.2.4". Although it built the app, it showed a fatal exception below when I started the activity with the ad.
E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-1
java.lang.NoClassDefFoundError: com.google.android.gms.common.GoogleApiAvailability
at com.millennialmedia.internal.utils.EnvironmentUtils.getAdInfo(EnvironmentUtils.java:356)
at com.millennialmedia.internal.utils.EnvironmentUtils$1.run(EnvironmentUtils.java:132)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)

Related

Trying to build on Android

I am trying to build my app but i received this error. I have rebuilt, cleaned progect and reset Android Studio. This is the screenshot of the problem:
Code error:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex 'C:\Users\User-1.gradle\caches\modules-2\files-2.1\stax\stax-api\1.0.1\49c100caf72d658aca8e58bd74a4ba90fa2b0d70\stax-api-1.0.1.jar' to 'C:\Users\User-1\Documents\workspace\WebUpHosting\app\build\intermediates\transforms\dex\debug\folders\1000\10\stax-api-1.0.1_4deeb811af0ea67608aa694ead937d7c9ac36202'
The problem is when i am building, because my app compiles right. Anyone knows how i could solve that?
UPDATE:
buil.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.webuphosting.app"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dexOptions {
preDexLibraries = false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.daimajia.easing:library:2.0#aar'
compile 'com.daimajia.androidanimations:library:2.3#aar'
compile 'com.android.support:support-v4:26.+'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
compile 'com.android.support:recyclerview-v7:26.0.+'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile "com.squareup.retrofit2:converter-simplexml:2.3.0"
testCompile 'junit:junit:4.12'
}
Hard to tell the exact problem with more code to see, but as a solution, you could just simply disable pre-dex:
boolean preDexLibraries
Whether to pre-dex libraries. This can improve incremental builds, but clean builds may be slower.
To do so, add the following block in your main module (app)'s build.gradle file, inside the android:
android {
// everything else
dexOptions {
preDexLibraries = false
}
}
By default, it is set to true, so by setting it to false, you could get around your issue, but it may not solve the root-cause.

Gradle build error after adding facebook dependency in Android Studio

I am creating an android app currently using firebase and facebook. I am trying to add a facebook login button, but when I add the line compile 'com.facebook.android:facebook-android-sdk:[4,5)' I get the error
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : Attribute meta-data#android.support.VERSION#value value=(26.0.0-alpha1) from [com.android.support:design:26.0.0-alpha1] AndroidManifest.xml:27:9-38
is also present at [com.android.support:cardview-v7:25.3.1] AndroidManifest.xml:24:9-31 value=(25.3.1).
Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:25:5-27:41 to override.
when I try to sync the gradle build. Here is what my app build.gradle file looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26"
defaultConfig {
applicationId "com.notnow.barapp"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:support-v4:26.+'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
It's because Facebook library use com.android.support:cardview-v7:25.3.1 and you cannot use different support library with different version number. I resolved downgrading compileSdkVersion to 25 and all the support library to 25.3.1. You can check that Facebook library is using com.android.support:cardview-v7:25.3.1 at the following link: Facebook Core Gradle
Hope it helps.

Application error after using .aar file in my android studio sample project

I am learning android and found this extension really helpful in learning.
I have added an .aar file from project
https://github.com/hbb20/CountryCodePickerProject
from the method i saw on youtube in my sample project, and thankfully did not get any error in complete process.
But when I installed my sample app's apk on phone, it is force closing on all android versions (6.0 and 7.1.1 i have checked). It is giving
Application Error - Unfortunately, the App has stopped
when I click on the picker which is perfectly seen on the screen.
But the issue is only country code picker is not coming on screen and application force closes.
Can you please help me with this.
I would be grateful to you.
I am assuming there is something issue in gradle. Don't know whether I am correct.
Here is the part which I have written in gradle
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.test.app"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.+'
testCompile 'junit:junit:4.12'
compile project(':ccp')
}

New AndroidStudio 2.3 Error

I have just installed new Android Studio and tried to create a new project. But I get this strange error. I am using 32 bit Linux system.
Error:Execution failed for task ':app:mergeDebugResources'.
Error: java.util.concurrent.ExecutionException: java.lang.RuntimeException: AAPT process not ready to receive commands
Information:BUILD FAILED
Error:java.util.concurrent.ExecutionException: java.lang.RuntimeException: AAPT process not ready to receive commands
Information:Total time: 14.838 secs
Information:2 errors
Information:0 warnings
Information:See complete output in console
I don't understand why I am getting this error.
Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.sandesh.testing"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
Gradle (project)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// 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
}
In your case problem is newest Android Studio does not run on 32bit only system. On download page you can check the requirement also:
64-bit distribution capable of running 32-bit applications
The newest version does not support 32bit. I think you should try with one solution but I dont know how long it will work :
Step1.Go to terminal
Step2.type gedit .profile
Step3.paste the below line at end of the page
Step4.export ANDROID_EMULATOR_FORCE_32BIT=true
Step5.type source .profile in terminal or restart system
Please remember that may be in future Android Stdio stop supporting this too so its better you should move to bit64 or downgrade your version of android studio.

Error:Execution failed for task ':app:dexDebug'.

I'm working on an android app using android studio for school and I'm trying to use Jersey client to connect the app with my web services. I'm getting the following error when I attempt to add the jars required for Jersey client and compile the project.
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
From searching around for a solution to this problem it seems to me it is occurring because I am exceeding a 65k limit on methods by adding the jars. I've also seen that this can be fixed by using multidex support which I have tried to implement but the error remains when I compile the gradle.
Here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.williamj.hertz"
minSdkVersion 15
targetSdkVersion 23
multiDexEnabled true
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions{
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
exclude 'META-INF/LISCENSE.txt'
exclude 'META-INF/LISCENSE'
exclude 'META-INF/liscense.txt'
}
dexOptions{
incremental true
preDexLibraries = false
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.parse:parse-android:1.10.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.github.flavienlaurent.datetimepicker:library:0.0.2'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:multidex:1.0.1'
}
And here is a portion of my AndroidManifest where I have added multidex support
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:largeHeap="true"
android:name="android.support.multidex.MultiDexApplication">
I'm assuming that I'm just not implementing multidex support correctly. Any help in fixing this error would be greatly appreciated, thank you.
Have your Application override attachBaseContext:
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
link: http://developer.android.com/tools/building/multidex.html
2nd methode:
I also noticed that you are including all Google play services:
compile 'com.google.android.gms:play-services:8.4.0'
You may be able to mitigate this problem when compiling your app by specifying only the specific Google Play services APIs your app uses, instead of all of them. For information on how to do this, see: https://developers.google.com/android/guides/setup#add_google_play_services_to_your_project

Categories

Resources