Android SDK VS Facebook R class conflict? - java

Okay first of all what I am doing is trying to integrate my Android game which is fully functional and tested to be working code onto Facebook.
I have been following the Facebook tutorial on how to set it up for Facebook and have been using the Android SDK version of the support v4 file.
The problem I have been having seems to be a conflict between the two SDK's.
R cannot be resolved to a variable.
For example
MediaPlayer song = MediaPlayer.create(this.getContext(), R.raw.ironman);
R.raw.ironman is where the problem occurs, which is a reference to the raw folder in my resources directory, where the mp3 file ironman is found.
It uses the R class which is part of the Android SDK
I had my game setup this way and it works great until I try to add the features from the tutorial.
For example
if (user != null)
{
TextView welcome = (TextView) findViewById(R.id.welcome);
welcome.setText("Hello " + user.getName() + "!");
}
R.id.welcome
This uses the R class which is part of the Facebook SDK for accessing a control the way it looks.
Another thing I noticed was that it keeps deleting my Java files as well.
from what I have read on other posts on here this is due to problems with the XML file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.SmashEm"
android:versionCode="2"
android:versionName="2.1" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#drawable/thumb"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:configChanges="orientation|keyboardHidden"
android:name="com.example.SmashEm.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:value="#string/app_id" android:name=" com.facebook.sdk.ApplicationId"/>
<activity android:name="com.facebook.LoginActivity" android:label="#string/app_name"></activity>
</application>
</manifest>
Maybe I am going about this all wrong but I just thought I would give this a try.
Any help would be a appreciated and thanks.
Also I am pretty sure this is different then all the other threads I read so far but I could be wrong since I am not an expert in Java.

Related

Trying to start Google Play Services Games example

I'm very new to Android studio, so this is probably a stupid question.
As of current I'm trying to follow this tutorial:
https://developers.google.com/games/services/android/quickstart
and got stuck at step 1 almost right off the bat. I downloaded the whole project as I'm trying to start and test "Typeanumber". Upon importing I went to "TypeaNumber" and changed the AndroidManifest.XML to a random domain. Quite obviously this didn't change anything. I still can't run the project and there're errors everywhere.
The XML looks like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pieps.testgame">
<application
android:supportsRtl="true"
android:allowBackup="true"
android:fullBackupContent="false"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="#string/app_id" />
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
<activity
android:name="com.google.example.games.tanc.MainActivity"
android:label="#string/title_activity_main"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
In the source, where I find the classes, there're like 5 directories that all seem exceptionally redundant. In the classes the wrong package is displayed as well.
Am I suppose to change all packages throghout the entire project(if so the documentation fails pretty hard)? What am I suppose to do to get this working?

PLACES_API_KEY_INVALID shown but everything seems to be done right

My app uses the Google Places API to function however when I use the line placeLikelihoods.getStatus().getStatusMessage() , I get the message PLACES_API_KEY_INVALID. I've been googling for days and can't find a solution. When I go to https://console.developers.google.com/apis/credentials?project=myprojectdebug and click on my project, I am redirected to a page that shows my API key, the date I made it and my email used to make it.
This is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="censored b/c its got some private stuff in name">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar">
<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" />
<meta-deta
android:name="com.google.android.geo.API_KEY"
android:value="My 39 character API key is here" />
</application>
What am I doing wrong? I feel like giving up but I also want to know what's wrong
EDIT: Found the problem however I can't fix it. I didn't use the proper keytool command shown here https://support.google.com/googleapi/answer/6158862 but when I run this command it gives me an error because my account name has a space between my first and last name thanks to me using a microsoft account.
Ok, i got your error. You misspell meta-data. Check your tag, you wrote 'meta-deta'
check this one in your manifest file i placed
android:name="com.google.android.maps.v2.API_KEY"
instead of this (place below one and check spelling)
android:name="com.google.android.geo.API_KEY"
in your AndroidManifest.xml file like
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/api_key"/>
1) Have you enable/activate google place api?
2) Did you keep switching your workstation? If you run your code using another pc (not the original one you use to generate api key), you need to request new API key because the debug key has changed.

unable to instantiate activity, ClassNotFoundException

I am developing an android application and after moving around some libraries and adjusting my workspace so that it can sync with github I am now encountering a new error that I have not had in the past. Here is the print out in LogCat.
FATAL EXCEPTION: main
Process: com.exmple.loop, PID:1000
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.example.loop/com.example.loop.MainActivity}:
java.lang.ClassNotFoundException: Didn't find class "com.example.loop.MainActivity" on
path: DexpathList[[zip file "/data/app/com.example.loop-2.apk"]...
I can supply more if needed. I have checked stackoverflow for solutions and came across some that proved to be unhelpful. Here is the first question I found and here is the second. I tried the helpful solutions for both and nothing seems to work. Similar to the user in the first question, the exception is thrown before any line I write because it is failing to recognize my main activity as a class.
Here is my android manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.loop"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:name="com.example.loop.LoopApplication"
android:icon="#drawable/loop_icon"
android:label="#string/app_name"
android:theme="#style/Theme.Loop" >
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<activity
android:name="com.example.loop.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:theme="#style/AppTheme" android:logo="#drawable/loop_icon" android:name="LoginActivity">
</activity>
</application>
</manifest>
If you look in your logcat it writes:
ComponentInfo{com.exmple.loop/com.example.loop.MainActivity}:
com.exmple.loop
I think it should be com.example.loop
Try remove this line and see if it works:
android:name="com.example.loop.LoopApplication"
Change your activity tag to this and it will run:
<activity
android:name="MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
There are many causes to this. I'll try to name as much as I can.
1.You tryed to add the library in your Java Build Path and not in the Android libraries.
rigt-click on your project> properties > Android. At the bottom there is a place for Android libraries.
2.Right-click your src folder>Build Path > Use as Source Folder
3.Right-click you src folder> Build Path> Configure output folder > set projects default output folder
4.Right-clikc project > Java Build Path > Order and Export > check Android Private Libraries
(You CAN'T have any library in Android Private Libraries and in the outside at the same time)
5.If you have set the project to use Maven and removed it after. Delete the bin folder and the pom.xml
6.Check if you R file is being generated. Delete it and see if it rebuild. If not look in your manifest or xml files for any error.
7.Check that Build Atomatically is checked.
Hope this help, I have had this that problem many times, and each time it was something else.
Good luck!
Edit: there is a 8 cause but this is not your case. Its if you forget to add the class to the manifest.
So after trying every bit of advice given to me I decided to create a new Android Project and copy all the files from the old project the appropriate folder in the new project. While this took a little bit of time that could have probably been shorter if I had messed with the original project some more, ultimately it did fix the error I was encountering and the project now runs.

Android "Hello World" Error

I'm new to Android development. I'm running Eclipse with the ADT plugin and installed all the necessary dependencies. I open up Eclipse, select 'New Android Applciation' and everything is set. When I run the app, I get an error message saying
/home/parallels/workspace/test/AndroidManifest.xml: 2: /home/parallels/workspace/test/AndroidManifest.xml: Syntax error: newline unexpected
So I look in Android Manifest and it's just the default, Eclipse generated code, right? What's the problem here?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.test.MainActivity"
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>
Is there any empty space above your first line in your manifest? That has to be at the very top. Also have you compiled anything successfully thus far? Maybe something didn't get imported properly. I recommend android studio. It's just Googles modified version of eclipse that specializes in android development. It comes with everything you need all ready to go.

Android - "The server could not process your apk. Try again.." error when uploading on market

So this is my Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx.xxxxxxxxxxxxxxxx"
android:versionCode="3"
android:versionName="1.02">
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar" >
<activity
android:name=".XXXXXXXXXActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".XXXXXXXXXXXXXXXX"></activity>
</application>
</manifest>
Each time I upload to the android market, I get the error:
The server could not process your apk. Try again..
I previously uploaded a few APKs, but now I decided to downgrade my app, because it works on 2.1, previously it was on minimum 2.3. And since i've changed the minSdkVersion it doesn't want to upload anymore.
Looks like Android market is down. If you look carefully, you will see that upload does not even happen. So that error message is misleading you. Lets wait till Google resolves this.
#o2genum
I reported the problem here:
https://support.google.com/androidmarket/developer/bin/request.py?contact_type=bugs
(under "problems with the developer console")
And sent them the URL to this report
Edit:
Just saw this in the console:
22 February 2012: Application uploading and editing issues.
We are aware of issues with uploading and editing applications in the Android Market Developer Console. We apologize for this inconvenience and are working to fix this as soon as we can.

Categories

Resources