I am developing a chat application for Android. But while trying to register with GCM, I am receiving the following error:
04-02 16:59:29.793 29773-30031/purepush.group101.talktoday W/InstanceID/Rpc: Found 10010
04-02 16:59:29.920 29773-30031/purepush.group101.talktoday W/System.err: java.io.IOException: SERVICE_NOT_AVAILABLE
04-02 16:59:29.922 29773-30031/purepush.group101.talktoday W/System.err: at com.google.android.gms.iid.zzc.zzb(Unknown Source)
04-02 16:59:29.922 29773-30031/purepush.group101.talktoday W/System.err: at com.google.android.gms.iid.zzc.zza(Unknown Source)
04-02 16:59:29.922 29773-30031/purepush.group101.talktoday W/System.err: at com.google.android.gms.iid.InstanceID.zzc(Unknown Source)
04-02 16:59:29.922 29773-30031/purepush.group101.talktoday W/System.err: at com.google.android.gms.iid.InstanceID.getToken(Unknown Source)
04-02 16:59:29.922 29773-30031/purepush.group101.talktoday W/System.err: at purepush.group101.talktoday.LoginActivity$GetGCMTokenTask.doInBackground(LoginActivity.java:240)
04-02 16:59:29.923 29773-30031/purepush.group101.talktoday W/System.err: at purepush.group101.talktoday.LoginActivity$GetGCMTokenTask.doInBackground(LoginActivity.java:211)
04-02 16:59:29.923 29773-30031/purepush.group101.talktoday W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:295)
04-02 16:59:29.923 29773-30031/purepush.group101.talktoday W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
04-02 16:59:29.923 29773-30031/purepush.group101.talktoday W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
04-02 16:59:29.923 29773-30031/purepush.group101.talktoday W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
04-02 16:59:29.923 29773-30031/purepush.group101.talktoday W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
04-02 16:59:29.923 29773-30031/purepush.group101.talktoday W/System.err: at java.lang.Thread.run(Thread.java:818)
04-02 16:59:29.958 29773-29773/purepush.group101.talktoday E/GcmReceiver: Failed to resolve target intent service, skipping classname enforcement
04-02 16:59:29.958 29773-29773/purepush.group101.talktoday E/GcmReceiver: Error while delivering the message: ServiceIntent not found.
I am obtaining GCM token using the following code:
InstanceID instanceID = InstanceID.getInstance(context);`
regToken = instanceID.getToken(getString(R.string.gcm_defaultSenderId), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
MANIFEST:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="purepush.group101.talktoday">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="purepush.group101.talktoday.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="purepush.group101.talktoday.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" />
<activity android:name=".ChatActivity" />
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="purepush.group101.talktoday" />
</intent-filter>
</receiver>
<service
android:name=".utils.GCMMessageListener"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
</application>
</manifest>
Build.Gradle (App Module)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "21.1.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId 'purepush.group101.talktoday'
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'org.apache.httpcomponents:httpmime:4.5.2'
compile 'org.apache.httpcomponents:httpclient:4.5.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.android.gms:play-services:8.4.0'
}
Now the funny thing is, this error occurs only on my Nexus 5 running 6.0.1 (Build: MMB29Q). I tested this application on my colleague's Samsung Note 4 running 5.1.1 and I was able to successfully register his device with GCM. I am getting this error with multiple of our applications using GCM only my Nexus 5.
Any help on this would be appreciated
Thanks!
Please check your "Nexus 5" clock, it should be exact, and try to change
buildToolsVersion "21.1.2"
to something like: buildToolsVersion "23.0.2" => i'm using this version and GCM working well with Android 6
Update:
I'm using this Method to register my GCM
public void getRegId() {
new AsyncTask<Void, Void, String>() {
#Override
protected String doInBackground(Void... params) {
try {
if (gcm == null) {
gcm = GoogleCloudMessaging.getInstance(getApplicationContext());
}
regid = gcm.register(R.string.gcm_defaultSenderId);
msg = "Device registered, registration ID=" + regid;
} catch (IOException ex) {
msg = "Error :" + ex.getMessage();
System.out.println("Error---" + ex.getMessage());
}
return msg;
}
#Override
protected void onPostExecute(String msg) {
System.out.println("Registerid---" + regid);
}
}.execute(null, null, null);
}
please try it and let me know.
Well, it turns out that my Google Play store wasn't working properly. I could view apps and install new ones but when I entered "My apps & games", it gave me the Check your connection and try again error. So, I am posting this solution for anyone who might be having a similar problem since I spend 4-5 days looking for errors and trying different fixes.
Note: This is only for rooted users.
Steps:
Open your FIle Manager. I used ES File Explorer.
Goto "/" or the root of your phone
There will be folder called etc
Inside etc, you'll see a file name hosts
Inside the hosts file, you'll see 2 IP addresses. The second one will vary depending upon your location
Add a # at the start of the 2nd IP Address. # will change that line to a comment
I recommend making a backup of the hosts file before editing.
Credits to "Ronny927": http://forum.xda-developers.com/showthread.php?t=2273994
I have faced the same situation some days ago, it is not the problem of GCM it is the problem of our internet connection. see below points for more understanding
you phone is connected to wifi but there is no internet from wifi, try to google in browser, if it is working perfectly then you should try some more things, like checking play services in your device and many more.
your phone's data pack could have been over , it means that you are connected to internet , but you won't get any kind of data from it. this error can not be identified without checking connection to your server.
You can get additional details from this link
How to fix Google Cloud Messaging Registration error: SERVICE_NOT_AVAILABLE?
Related
I've asked a question before where my app was working only on the emulator but not a real device, here's a link of it:
Firebase database is not updating with no errors, slow response
unfortunately, I wasn't able to figure out the issue or solve it. So, I started from scratch and build a simple app that writes "TEST" to a real-time database, and the same issue was there, the app is working ONLY on the emulator but not my real device.
So, I figured out that the app is not able to connect to firebase when I ran it in my device. But I couldn't figure out why?
Here's my main activity:
package com.example.alice.testingfirebase;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
public class MainActivity extends AppCompatActivity {
private DatabaseReference mDatabase;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDatabase = FirebaseDatabase.getInstance().getReference();
for (int i = 0; i<10;i++) {
String id = i+"";
mDatabase.child("users").child(id).setValue("TEST");
}
}
}
Here's my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.alice.testingfirebase">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
and here's my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.alice.testingfirebase"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'
The rules of the database are set to be public.
After adding the INTERNET permission, the app keeps stopping, and here's part of the log cat:
09-09 14:39:55.374 21502-21537/com.example.alice.testingfirebase V/FA: Connection attempt already in progress
09-09 14:39:55.455 21502-21502/com.example.alice.testingfirebase D/AndroidRuntime: Shutting down VM
09-09 14:39:55.456 21502-21502/com.example.alice.testingfirebase E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.alice.testingfirebase, PID: 21502
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.alice.testingfirebase/com.example.alice.testingfirebase.MainActivity}: com.google.firebase.database.DatabaseException: Calls to setLogLevel() must be made before any other usage of FirebaseDatabase instance.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2955)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: com.google.firebase.database.DatabaseException: Calls to setLogLevel() must be made before any other usage of FirebaseDatabase instance.
at com.google.firebase.database.FirebaseDatabase.zzb(Unknown Source:38)
at com.google.firebase.database.FirebaseDatabase.setLogLevel(Unknown Source:3)
at com.example.alice.testingfirebase.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:7183)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2908)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
09-09 14:39:55.472 21502-21551/com.example.alice.testingfirebase W/zygote64: Skipping duplicate class check due to unrecognized classloader
09-09 14:39:55.474 21502-21551/com.example.alice.testingfirebase I/DynamiteModule: Considering local module com.google.android.gms.firebase_database:4 and remote module com.google.android.gms.firebase_database:6
09-09 14:39:55.475 21502-21551/com.example.alice.testingfirebase I/DynamiteModule: Selected remote version of com.google.android.gms.firebase_database, version >= 6
09-09 14:39:55.506 21502-21551/com.example.alice.testingfirebase W/zygote64: Skipping duplicate class check due to unrecognized classloader
09-09 14:39:55.567 21502-21559/com.example.alice.testingfirebase D/NetworkSecurityConfig: No Network Security Config specified, using platform default
09-09 14:39:55.573 21502-21559/com.example.alice.testingfirebase D/TcpOptimizer: TcpOptimizer-ON
09-09 14:40:00.281 21502-21521/com.example.alice.testingfirebase I/zygote64: WaitForGcToComplete blocked for 22.520ms for cause HeapTrim
09-09 14:40:00.286 21502-21521/com.example.alice.testingfirebase W/zygote64: Suspending all threads took: 5.439ms
For developers using VIVO and OPPO phones, these brands have a strange problem connecting to Firebase. I have 7 devices of different makes and configurations for testing purposes and all of them connect except these two. There are no errors and no exceptions. They just refuse to connect. Just wanted to float this point out so developers using these phones know about the problem.
Please add this to your manifest file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.alice.testingfirebase">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"..
....
</application>
</manifest>
Also edit your MainActivity like
FirebaseDatabase obj= FirebaseDatabase.getInstance();
DatabaseReference mDatabase= obj.getReference();
for (int i = 0; i<10;i++)
{
String id = i+"";
mDatabase.child("users").child(id).setValue("TEST");
}
First, you don't have internet permission in your AndroidManifext.xml and I'm still wondering how it does works on the emulator.
Second, initialize FirebaseDatabase then DatabaseReference to be able to read-write data in Firebase Realtime database:
// Write a message to the database
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference().child("users").child("id"); //location to put, can be anything you want ...
myRef.setValue("TEST");
Also, are you sure this is what you want? Putting String in an id field? Consider checking your FireBase Database in console!
Read: https://firebase.google.com/docs/database/android/start
I've tried and tried and tried to figure this problem out. I've searched everywhere and I haven't found a solution yet. I understand that there are many forums on this topic, but none have helped me come up with a solution.
The problem I'm having is that when I run my android application, in the emulator, the area for the map comes up only with grey tiles. I've read online that the problem is most likely the Google API key, but I've tried multiples way to generate it (Used the Android Studio Terminal to obtain SHA1, I had Android studio generate a link to google so it can automatically create the key).
I'm hoping someone can help me out, I'm pretty desperate here!
Here's my Activity class
package com.bignerdranch.android.taskmanager;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
public class AddLocationMapActivity extends MapActivity {
public static final String ADDRESS_RESULT = "address";
#Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.add_location);
}
#Override
protected boolean isRouteDisplayed() {
return false;
}
#Override
protected boolean isLocationDisplayed() {
return true;
}
}
This is the layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/location_title"
.../>
<EditText
android:id="#+id/task_address"
.../>
<Button
android:id="#+id/map_location_button"
.../>
<com.google.android.maps.MapView
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/map_location_button"
android:layout_above="#+id/use_this_location_button"
android:clickable="true"
android:apiKey="AIza.................................." />
<Button
android:id="#id/use_this_location_button"
.../>
</RelativeLayout>
Then, this is the manifest file:
?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bignerdranch.android.taskmanager">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:name=".TaskManagerApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIza..........................." />
<activity android:name=".ViewTasksActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".AddTaskActivity"
android:text="#string/add_task"/>
<activity android:name=".AddLocationMapActivity"
android:text="#string/add_location_to_task"/>
<uses-library android:name="com.google.android.maps" />
</application>
</manifest>
Then the build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:24'
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.bignerdranch.android.taskmanager"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
}
And lastly, this is what is generated by the Monitor:
12-02 22:37:10.351 22387-22537/com.bignerdranch.android.taskmanager W/System.err: IOException processing: 26
12-02 22:37:10.351 22387-22537/com.bignerdranch.android.taskmanager W/System.err: java.io.IOException: Server returned: 3
12-02 22:37:10.352 22387-22537/com.bignerdranch.android.taskmanager W/System.err: at android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileRequest.readResponseData(BaseTileRequest.java:115)
12-02 22:37:10.352 22387-22537/com.bignerdranch.android.taskmanager W/System.err: at android_maps_conflict_avoidance.com.google.googlenav.map.MapService$MapTileRequest.readResponseData(MapService.java:1473)
12-02 22:37:10.352 22387-22537/com.bignerdranch.android.taskmanager W/System.err: at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.processDataRequest(DataRequestDispatcher.java:1117)
12-02 22:37:10.352 22387-22537/com.bignerdranch.android.taskmanager W/System.err: at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.serviceRequests(DataRequestDispatcher.java:994)
12-02 22:37:10.352 22387-22537/com.bignerdranch.android.taskmanager W/System.err: at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher$DispatcherServer.run(DataRequestDispatcher.java:1702)
12-02 22:37:10.352 22387-22537/com.bignerdranch.android.taskmanager W/System.err: at java.lang.Thread.run(Thread.java:818)
I WOULD BE FOREVER GRATEFUL TO THE PERSON WHO CAN HELP ME FIGURE THIS PROBLEM OUT!
Grey tiles instead of map
The map that you're using com.google.android.maps.MapView is a v1 of Google Map API. Unfortunately, it is officially deprecated.
You should use the new version of Google Maps API which is Version 2
Here's a tutorial for Google Map V2
I am new to android and i try to integrate Paypal in Android. I follow this official tutorial
https://github.com/paypal/PayPal-Android-SDK/blob/master/docs/single_payment.md
I got the following error
uses-sdk:minSdkVersion 15 cannot be smaller than version 16 declared in library [com.paypal.sdk:paypal-android-sdk:2.14.3] /home/developer/Desktop/Jac - Android/jac/build/intermediates/exploded-aar/com.paypal.sdk/paypal-android-sdk/2.14.3/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="com.paypal.android.sdk.payments" to force usage
I write this code in the menifest file and this error removes:
xmlns:tools="http://schemas.android.com/tools">
<uses-sdk tools:overrideLibrary="com.paypal.android.sdk.payments"/>
But it generate few more errors:
FATAL EXCEPTION: OkHttp Dispatcher
Process: com.knysys.jac.jaclassified, PID: 1982
java.lang.NoSuchMethodError: No virtual method log(Ljava/lang/String;)V in class Lokhttp3/internal/Platform; or its super classes (declaration of 'okhttp3.internal.Platform'
appears in /data/app/com.knysys.jac.jaclassified-2/base.apk)
at okhttp3.logging.HttpLoggingInterceptor$Logger$1.log(HttpLoggingInterceptor.java:108)
at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:157)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:190)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:163)
at okhttp3.RealCall.access$100(RealCall.java:30)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:127)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
I have these dependencies in my gradle still i get these issues
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta3'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta3'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.0-RC1'
Where am i wrong. Why it generate such an error. Any help or any other solution to achieve that. Thankyou.
read this link and follow these steps.
http://www.articlesbase.com/online-education-articles/how-to-integrate-paypal-in-eclipse-and-android-studio-7389133.html
Make changes in your manifest :-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.javatpoint.hello"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="" //change minSDK to 16 or more
android:targetSdkVersion="" /> //change targetSdk to 19 or more
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
API Version Incompatibilities
I have made an app using android studio, until now I have been testing it on a 'Nexus 5X (API 23) emulator'. However, today i started debugging the app on a 'Samsung Galaxy Tab 2 7.0 (API 18)' and the app will not even start. I know this is because of incompatibilities between the API's specifically something to do with the Theme i'm using. What i want to know is how i can fix this problem without changing the look of the app drastically.
Log Cat Crash Log
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.***.********/com.***.********.MenuActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2295)
at android.app.ActivityThread.access$700(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:175)
at android.app.ActivityThread.main(ActivityThread.java:5279)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:124)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:146)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59)
at com.***.*******.MenuActivity.onCreate(MenuActivity.java:47)
at android.app.Activity.performCreate(Activity.java:5283)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2295)
at android.app.ActivityThread.access$700(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:175)
at android.app.ActivityThread.main(ActivityThread.java:5279)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<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=".MenuActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".About" />
<activity android:name=".SettingsActivity" />
<activity android:name=".********Activity" />
<activity android:name=".********Activity" />
<activity
android:name=".VideoPlayerActivity"
android:screenOrientation="landscape" />
<activity android:name=".*******Activity"></activity>
</application>
Gradle Build App File
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.***.*******"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "2.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:22.2.1'
compile 'com.android.support:design:22.2.1'
}
Note: The last two lines (the ones with compile...) are underlined in red and say 'This support library should not use a different version(22) than the compile SDK version(21).'
Edit: If I change the Theme for the main activity to '#style/Theme.AppCompat.NoActionBar' the application will start however, the look of the application changes. Also, other activities that do not use the new theme work fine.
Any Help is Appreciated.
I get this error message:
Caused by: com.xtify.android.sdk.InvalidFormatException: Could not read the api key. No meta data found in the manifest file.
at com.xtify.android.sdk.PersistentLocationManager.a( Unknown Source)
at com.xtify.android.sdk.PersistentLocationManager.c( Unknown Source)
at com.xtify.android.sdk.PersistentLocationManager.a( Unknown Source)
at com.xtify.android.sdk.PersistentLocationManager.<i nit>(Unknown Source)
at com.nejo.android.xtify.nejoXTIFY.initialize(nejoXT IFY.java:27)
at Xtracard.Customer.xti._service_create(xti.java:102 )
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
... 13 more
This is in my manifest file:
<receiver android:name="com.nejo.android.xtify.NejoXtyreceiv er">
<intent-filter androidriority="9999">
<action android:name="com.xtify.android.sdk.SHOW_NOTIFICAT ION" />
<!-- KEEP THE FORWARD SLASH IN FRONT OF THE APP KEY ON THE LINE BELOW -->
<data android:scheme="notif" android:host="notification.xtify.com"
androidathPrefix="/a0ef3978-dcb9-424d-9b03-1567f5814817" />
</intent-filter>
</receiver>
The API key is correct. Xtifys support page throws an error when I ask them a question.
Any ideas?