I am developing a Android Studio project using gradle 2.2 and Google Play Services 12.0.1. I am now trying to add functionality from Google Play Services.
The thing is I am unable to import the Google Play Service library. When I try the following line.
import com.google.android.gms.games.Games;
Or anything similar i get "Cannot resolve symbol Games", Android Studio proposes "Add library <...> to classpath" but that does not seem to change anything.
What I have done so far
I started out following this setup guide. Which simply says to update your build.gradle. My top-level build.gradle contains this,
project(":android") {
apply plugin: "android"
apply plugin: 'com.android.application'
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
< ... >
compile "com.google.android.gms:play-services-games:12.0.1"
}
}
I have also ensured that the buildscript section contains the maven link. I have also checked that Google Play Services are installed from the "SDK Tools" pane in the SDK manager. In addition to this I have added the correct version of Play Services as a dependency in Project structure -> Modules -> Dependencies. Someone suggested on earlier Stack Overflow questions that adding
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
to the AndroidManifest might help, so my Manifest looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="wizard_team.wizards_tale" >
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="27" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/GdxTheme" >
<activity
android:name="wizard_team.wizards_tale.AndroidLauncher"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
I do not receive any error messages when I resync and I have tried to update and restart Android Studio several times. I have also tried "Invalidate chaches/restart..".
During my quest on Google I have found several people experiencing the same problem and I have tried their solutions but nothing has worked. I have spent way to long with this problem, does anyone have any suggestions?
Solved it. As I do not have much experience creating apps I tried importing google play services into the core-module part of my app. For anyone else just getting started, the android specific code such as this should go in android -> java -> [package-name].
Might seem trivial, but as a beginner using this setup tool this problem kept me searching for hours.
Related
I tried to install my application in an Android version 12. I added the android:exported for each activity, receiver and filters. This error occurs
Installation did not succeed.
The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED
List of apks:
[0] 'C:\Users\Code\MyApp\app\build\outputs\apk\debug\app-debug.apk'
Installation failed due to: 'Failed to commit install session 366841949 with command package install-commit 366841949. Error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl366841949.tmp/base.apk (at Binary XML file line #392): androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present'
Retry
Failed to launch an application on all devices
The merged manifist displays these errors
Error: android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. myapp.app main manifest (this file), line 26
Error: android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. muapp.app main manifest (this file), line 33
Error: android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. myapp.app main manifest (this file), line 40
This is the test AndroidManifest.XML file that causes the errors
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="androidx.test.core" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.REORDER_TASKS" />
<application>
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity"
android:theme="#android:style/Theme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity"
android:theme="#android:style/Theme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity"
android:theme="#android:style/Theme.Dialog" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
</manifest>
These are the test dependencies I'm using
debugImplementation 'androidx.fragment:fragment-testing:1.3.5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0')
androidTestImplementation('androidx.test:runner:1.4.0')
androidTestImplementation('androidx.test:rules:1.4.0')
The problem occurs in the test package and its auto generated. How to fix it?
I tried multiple solutions to fix the problem but nothing seems to fix it.
These are some solutions I looked into but didn't work for me.
Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]
An API level of 31 is not supported by this compiler. Please use an API level of 30 or earlier
The error was fixed by changing this dependency version androidx.fragment:fragment-testing
from version 1.3.5
debugImplementation 'androidx.fragment:fragment-testing:1.3.5'
to version 1.4.0
debugImplementation 'androidx.fragment:fragment-testing:1.4.0'
This answer helped me fix the error https://stackoverflow.com/a/71605255/9770844
I have created a basic Android project following this guide.
Now when I run gradle(version 2.10) in my command line I get the following error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/opt/android-sdk/build-tools/23.0.2/aapt'' finished with non-zero exit value 1
This is my build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
}
And here is my AndroidManifest.xml file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.hello"
android:versionCode="1"
android:versionName="1.0.0" >
<application android:label="#string/app_name" >
<activity
android:name=".HelloActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Funny thing is, when I start Android Studio(1.5) and build a test application there it works fine, but doing it in command-line fails. I tried copying the gradle file from AS, to no avail. I checked the installation path, aapt is where it is supposed to be.
I'm quite lost here since I used that very same guide from above a few months ago. Today I updated my Android SDK installation(EDIT: I made sure the right revisions are installed) but I can't get anything to build properly.
Let me know if you need more information, I'm stuck.
I figured it out myself. After reinstalling Gradle, I finally got a new error message that told me in plain english what was wrong(it was a problem with my resources).
This is really weird, since I use Archlinux and all other Gradle updates worked fine before.
Thanks anyway to whomever has given this some thought :)
we are sooooo close to finishing our game, it is ready to be published through google play but we are having problems making any of the game services work.
we have a simple achievement button that should call the achievement UI, same goes for logging in. but we do not get any prompts when we are running it on our android device.
we have
PlayGamesPlatform.Activate();
in our start function
Social.localUser.Authenticate((bool success) => {
// handle success or failure
});
connected to a log in button
and
Social.ShowAchievementsUI();
on our show achievement button.
our email is connected as a tester on google play and the game service API's are all enabled
my real question is about the AndroidManifest that the game play service for unity created.
this is it:
<?xml version="1.0" encoding="utf-8"?>
<!-- This file was automatically generated by the Google Play Games plugin for Unity
Do not edit. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.example.games.mainlibproj"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" />
<application>
<!-- Required for Nearby Connections API -->
<meta-data android:name="com.google.android.gms.nearby.connection.SERVICE_ID"
android:value="" />
<!-- the space in these forces it to be interpreted as a string vs. int -->
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="\ 606268116612" />
<meta-data android:name="com.google.android.gms.appstate.APP_ID"
android:value="\ 606268116612" />
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity android:name="com.google.games.bridge.NativeBridgeActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
</application>
</manifest>
i have read online that the package name should be our package name but shouldnt this be created when we run android set up using our ID number for our game? should i physically change this in code in the manifest even though it says i shouldnt edit it?
also OUR.ID i have replaced just for this question and in the real manifest has our actual ID No
Many Thanks In Advance
I always have the same package name (at application level) than my hierarchy in the project. In my opinion is a good practice to set the root at the folder where you have all your activities.
On the other hand, you can sign your app for market with the ID you want setting it in your gradle file.
You can see a good reference here.
I hope this would help you.
So essentially I've been making a game using libgdx and just recently I started to try and add Google Play Game Services and So I tried my hand at it and it seems as though I have completely messed up my .xml file I've tried looking at questions such as How do I resolve this Java Class not found exception? and NoClassDefFoundError - Eclipse and Android, but to no avail.
Here is the runtime error I am recieving.
02-19 19:25:17.772: E/AndroidRuntime(25746): FATAL EXCEPTION: main
02-19 19:25:17.772: E/AndroidRuntime(25746): Process: com.coppercow.minerman, PID: 25746
02-19 19:25:17.772: E/AndroidRuntime(25746): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.coppercow.minerman/com.coppercow.minerman.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.coppercow.minerman.MainActivity" on path: DexPathList[[zip file "/data/app/com.coppercow.minerman-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.coppercow.minerman-2, /vendor/lib, /system/lib]]
The class Name is MainActivity.Java and it is in the src file. I understand that this is done because of one of two things: My .class file, or the .xml file. So here is also my .xml file just in case what I have done wrong is there and not in fact in any .class file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.coppercow.minerman"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
However I've messed around with this xml file quite a lot and so I do not believe it is in here and that My whole problem has to be in some .class file somewhere, but I don't even understand how to access those from eclipse from going off of other questions asked here on StackOverflow.
Try this:
Go to Project/Properties/Java Build Path/Order and Export -- Make sure there's a check in front of Android Dependencies and the support library, if you use it.Mark all checkboxes and Click on Apply and clean the project.
Hope this helps.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android">
<application android:icon="#drawable/ic_launcher" android:label="#string/app_name">
<activity android:name=".hba1c" android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I'm trying to learn Java and need some help with AndroidManifest.xml
My little hello world project is working code-wise, but I'm confused with making changes to the manifest. Specifically, in the code above package name is "com.android" and in data/app my app shows up as com.android-1.apk. When I try to change it to something like com.jocala or com.jocala.hba1c I get package R does not exist errors through my compile, which fails.
What changes do I need to make? Anything else here that is glaringly bad?
I am working using Ant, VI and the Linux console, no Eclipse.
You should change the package of the java code, let it in accordance with the package which you defined in the manifest file.
The manifest holds meta-data corresponding to your android application. Hence, if you needs changes in the package name, make the changes in the java files, change the package name there, there is no sense making a change here. The only changes that are majorly done in the manifest are activity related(for beginners). Have a read here.