I can't add google-play-services.jar in my project in android studio 0.4.6 - android-studio

There are my actions:
1) Add file google-play-services.jar from sdk directory in "libs" directory in my project.
2) Add dependency "compile files('libs/google-play-services.jar')" in build.gradle in my project (not in solution).
Sync Project is complete succesfully, but after running application i see that error:
Execution failed for task ':TestMcSiRun:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
D:\SDK\sdk\sdk\build-tools\19.0.2\dx.bat --dex --output C:\Users\MCSIMUSIC\AndroidStudioProjects\TestMcSiRun\TestMcSiRun\build\dex\debug C:\Users\MCSIMUSIC\AndroidStudioProjects\TestMcSiRun\TestMcSiRun\build\classes\debug C:\Users\MCSIMUSIC\AndroidStudioProjects\TestMcSiRun\TestMcSiRun\build\dependency-cache\debug C:\Users\MCSIMUSIC\AndroidStudioProjects\TestMcSiRun\TestMcSiRun\build\pre-dexed\debug\classes-2b5c8c8b2a23992eb9323b131861658b5a6c4592.jar C:\Users\MCSIMUSIC\AndroidStudioProjects\TestMcSiRun\TestMcSiRun\build\pre-dexed\debug\classes-442363482f1c8783c26a5e38b6ee593d3f54a067.jar C:\Users\MCSIMUSIC\AndroidStudioProjects\TestMcSiRun\TestMcSiRun\build\pre-dexed\debug\google-play-services-da249c1d3c777ecbc074adaa5e3cd781485d270c.jar C:\Users\MCSIMUSIC\AndroidStudioProjects\TestMcSiRun\TestMcSiRun\build\pre-dexed\debug\support-v4-18.0.0-00a4eeb2a43f491f4d8b1d7286b2ebe4b40b994e.jar
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
What do I do wrong?
my build.gradle:
apply plugin: 'android'
android {
compileSdkVersion 18
buildToolsVersion '19.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 15
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:18.0.+'
compile 'com.google.android.gms:play-services:4.0.30'
//compile files('libs/google-play-services.jar')
}

You have something like this:
dependencies {
compile 'com.google.android.gms:play-services:4.0.30'
compile files('libs/google-play-services.jar')
}
But that's including the library twice. It's sufficient to have just this:
dependencies {
compile 'com.google.android.gms:play-services:4.0.30'
}
It will compile correctly, and it will include the right library in your APK.

Related

Error:Execution failed for task :app:transformClassesWithJarMergingForRelease

Hello i have a problem and i need some help
i want to integrate facebook Sdk in my project to facebook ads to get installs and i got some errors
This is the error :
Error:Execution failed for task'
:app:transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry: android/support/v4/media/TransportPerformer.class
And this is my build.gradle code :
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.example.example"
minSdkVersion 15
targetSdkVersion 24
multiDexEnabled true
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets.main {
jni.srcDirs = []// <-- disable automatic ndk-build call}
}
`repositories {
mavenCentral()
}
dependencies {
compile('com.google.android.gms:play-services:+'){exclude module: 'support-v4'}
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
compile 'com.facebook.android:facebook-android-sdk:[4,5)'}`
Have you tried to run './gradlew clean' in your project?

Android Studio - error: linker command failed with exit code 1

I downloaded the code from this repository (its a app to control a parrot drone):
Github
with the hopes of getting it to work so i can study the code, however im getting this error that seems hard to find a solution after searching the web, i mostly found things for IOS, xcode, etc
I imported the project into android studio, when i try to execute the app i get the following error:
Error:error: linker command failed with exit code 1 (use -v to see invocation)
I am not really into NDK, but from what i saw it could be the reason, things i tried:
Downloaded NDK and added the correct path to it.
Using latest SDK.
Changes to build.gradle like setting buildToolsVersion "25.0.0", etc
Build.gradle (Project: ardrone)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
}
}
allprojects {
repositories {
jcenter()
}
}
Build.gradle (Module:app)
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
multiDexEnabled true
applicationId "com.parrot.freeflight"
minSdkVersion 9
targetSdkVersion 24
versionCode 20000
versionName "2.0-SDK"
ndk {
moduleName "adfreeflight"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
// TODO proguard-rules seem outdated and useless cause it's only Android stuff
}
}
sourceSets.main {
jni.srcDirs = [] // This prevents the auto generation of Android.mk
jniLibs.srcDir 'src/main/jniLibs'
// This is not necessary unless you have precompiled libraries in your project.
}
task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
def ndkCommand = "${android.ndkDirectory}/ndk-build"
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
ndkCommand += ".cmd"
}
commandLine ndkCommand,
'-C', file('src/main/jni').absolutePath,
'-j', Runtime.runtime.availableProcessors(),
'all',
'NDK_DEBUG=1'
}
task cleanNative(type: Exec, description: 'Clean JNI object files') {
def ndkCommand = "${android.ndkDirectory}/ndk-build"
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
ndkCommand += ".cmd"
}
commandLine ndkCommand,
'-C', file('src/main/jni').absolutePath,
'clean'
}
clean.dependsOn 'cleanNative'
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn buildNative
}
}
dependencies {
compile 'com.google.android.gms:play-services:10.0.0'
compile files('libs/android-support-v13.jar')
compile files('libs/com.sony.rdis.receiver-20111206.jar')
compile files('libs/com.sony.rdis.receiver.utility-20111206.jar')
}
local.properties
ndk.dir=C\:\\Users\\BugDroid\\AppData\\Local\\Android\\Sdk\\ndk-bundle
sdk.dir=C\:\\Users\\BugDroid\\AppData\\Local\\Android\\Sdk
You need to check your log for more details as the error 'Linker command failed with exit code 1' is usually followed by the more detailed error.
So to find more details, in Xcode click on the error under Buildtime and choose Reveal in log. This should give you extra hint. Without any specific error, it's difficult to know what's the problem.

Failed to resolve Junit:Junit:12

I am getting following error when I tried to run my first app in android studio
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugUnitTestCompile'.
> Could not resolve junit:junit:4.12.
Required by:
Hellow_World:app:unspecified
> Could not resolve junit:junit:4.12.
> Could not get resource 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> Could not GET 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> jcenter.bintray.com
Following is my Gradle.script(Module)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.administrator.hellow_world"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
}
Following is my Gradle.script(Hellow_World)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.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
}
Can somebody help me fixing this mess?
Please follow the below mentioned path:
Right click on your application/project ->
open module settings->
Go to "Dependencies" tab ->
you'll find "junit:junit:4.12" ->
select it and right click and choose remove option -> ok
Now again try to build your application.
Remove the below line in your code
testCompile 'junit:junit:4.12'
then compile it .

gradle: Execution failed for task ':myApp:processDebugManifest'

I have am really stumped...
I have an Android Studio (version 1.4) project consisting of two modules - androidLVL and myApp. When I attempt to build the project (Build -> Rebuild Project) I get these messages:
:myApp:processDebugManifest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':myApp:processDebugManifest'.
> java.lang.NullPointerException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Previous answers to this question indicate the error can be caused by incompatible sdk version numbers in the gradle build files - but I can't figure out what the correct versions should be. I edited the build files, but to no avail. Can someone please help? Here are the two gradle build files:
androidLVL:
apply plugin: 'com.android.library'
android {
// compileSdkVersion 22
compileSdkVersion 'Google Inc.:Google APIs:8'
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 10
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile 'com.google.android.gms:play-services:4.2.42'
compile 'com.android.support:appcompat-v7:22.0.+'
}
myApp:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:8'
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.tomoreilly.myApp"
minSdkVersion 10
targetSdkVersion 22
compileSdkVersion 22
}
buildTypes {
release {
minifyEnabled true
proguardFiles 'proguard-android.txt', 'proguard-project.txt'
}
}
}
dependencies {
compile project(':androidLVL')
compile files('libs/acra-4.2.3.jar')
compile files('libs/htmllexer.jar')
// compile "com.android.support:appcompat-v7:21.0.3"
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.google.android.gms:play-services-ads:8.1.0'
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
}
(Re the error message suggestion to 'run with --stacktrace option' etc. - I do not know how to invoke these options from within Android Studio).

Error:(24, 0) Project with path ':wear' could not be found in project ':mobile'. Android Studio

I got the following error in Android Studio while creating project...
Error:(24, 0) Project with path ':wear' could not be found in project ':mobile'.
This is my build.gradle file code, I want to resolve this issue. Any help appreciated...
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.user.usereventdemo"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
wearApp project(':wear')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
}
Looking at your settings.gradle, is it including :wear,?
if you don't want codes of wear, then delete :wear, and wearApp project(':wear') in your build.gradle.
if you want, then you have to find codes of wear, I'm afraid.
Under Gradle Scripts folder in Android Studio, locate "settings.gradle".
Open it and add ':wear' to the end of include statement.
It should look something like this:
include ':mobile', ':glass', ':wear'

Resources