Boo Boo - 16 days ago 12
Android Question

playgameservices/android-basic-samples tutorial for Android Studio

I've been trying to set up the basic samples in Android Studio for awhile now with no luck. This is what I've tried so far; I've downloaded the samples as a zip and then extracted it in my Android Studio Projects folder. Next I open Android Studio and select File->New->Import Project and then select the Basic Sample Folder (Note: there is no Select "Import from existing model - Gradle" as the ReadMe file instructs). I get an error telling me that it can not find the build tools version , so I just hard coded in the build tools version like so:

if (!project.hasProperty('android_version')) {
ext.build_tools_version = "23.0.2"
}else{
ext.build_tools_version = project.getProperty('android_version')
}


next I was getting an error telling me the min version couldn't be below 15 and so I went through the gradle files and changed the min version from 9 to 15. After this it asks me to upgrade my Gradle Plugin.


To take advantage of all the latest features (such as Instant Run),
improvements and security fixes, we strongly recommend that you update
the Android Gradle plugin to version 2.2.0 and Gradle to version
2.14.1.


If I don't upgrade the program it compiles but when I run it I get this error:


10:44:33 AM UnsupportedMethodException
Unsupported method: AndroidProject.getPluginGeneration().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.


If I do update the Gradle Plugin I get these two errors, failed to crunch file:


Error:com.android.builder.internal.aapt.AaptException: Failed to
crunch file
C:\Users\Me\AndroidStudioProjects\android-basic-samples-master\BasicSamples\libraries\BaseGameUtils\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.2.0\res\drawable-xhdpi-v4\abc_textfield_search_default_mtrl_alpha.9.png
into
C:\Users\Me\AndroidStudioProjects\android-basic-samples-master\BasicSamples\libraries\BaseGameUtils\build\intermediates\res\merged\androidTest\debug\drawable-xhdpi-v4\abc_textfield_search_default_mtrl_alpha.9.png

Error:Execution failed for task
':libraries:BaseGameUtils:mergeDebugAndroidTestResources'.


Error: com.android.builder.internal.aapt.AaptException: Failed to crunch file
C:\Users\Me\AndroidStudioProjects\android-basic-samples-master\BasicSamples\libraries\BaseGameUtils\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.2.0\res\drawable-xhdpi-v4\abc_textfield_search_default_mtrl_alpha.9.png
into
C:\Users\Me\AndroidStudioProjects\android-basic-samples-master\BasicSamples\libraries\BaseGameUtils\build\intermediates\res\merged\androidTest\debug\drawable-xhdpi-v4\abc_textfield_search_default_mtrl_alpha.9.png



So that's about as far as I've gone, I'm really only interested in running the SkeletonTbmp application, so maybe it would be more straightforward to try and set up each project individually. If anyone can see where I'm going astray I'd appreciate any help / advice offered.

Thanks

Answer

You're probably opening the incorrect folder. Make sure that the folder you are importing in Android Studio is the entire android-basic-samples folder:

enter image description here

After you import, synchronize gradle and then configure the sample you're trying to run as an Android module.

If that doesn't work, try building the samples from the command-line in the android-basic-samples folder:

cd android-basic-samples/BasicSamples
./gradlew assemble
find . -iname *.apk
...

You may also want to try changing line 44 of BasicSamples/libraries/BaseGameUtils/build.gradle to:

buildToolsVersion "23.0.2"

Change the minimum SDK version in BasicSamples/build.gradle to:

android_min_sdk_version = 15
Comments