EDIT:
The error was occurring with ORMLite version 4.48. I rolled back to 4.45 and the error stopped happening.
I've implemented a database using ORMLite for Android following the directions on the website. However, any time I try and write to the database, I get an exception:
10-24 15:15:04.600: E/AndroidRuntime(12057): FATAL EXCEPTION: IntentService[com.mypackage.instagram.UpdateInstagramPhotosService]
10-24 15:15:04.600: E/AndroidRuntime(12057): java.lang.ExceptionInInitializerError
10-24 15:15:04.600: E/AndroidRuntime(12057): at com.j256.ormlite.android.AndroidDatabaseConnection.compileStatement(AndroidDatabaseConnection.java:146)
10-24 15:15:04.600: E/AndroidRuntime(12057): at com.j256.ormlite.table.TableUtils.doStatements(TableUtils.java:460)
10-24 15:15:04.600: E/AndroidRuntime(12057): at com.j256.ormlite.table.TableUtils.doCreateTable(TableUtils.java:443)
10-24 15:15:04.600: E/AndroidRuntime(12057): at com.j256.ormlite.table.TableUtils.createTable(TableUtils.java:220)
10-24 15:15:04.600: E/AndroidRuntime(12057): at com.j256.ormlite.table.TableUtils.createTable(TableUtils.java:53)
10-24 15:15:04.600: E/AndroidRuntime(12057): at com.mypackage.database.DatabaseHelper.onCreate(DatabaseHelper.java:33)
10-24 15:15:04.600: E/AndroidRuntime(12057): at com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper.onCreate(OrmLiteSqliteOpenHelper.java:209)
10-24 15:15:04.600: E/AndroidRuntime(12057): at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:252)
10-24 15:15:04.600: E/AndroidRuntime(12057): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
10-24 15:15:04.600: E/AndroidRuntime(12057): at com.j256.ormlite.android.AndroidConnectionSource.getReadWriteConnection(AndroidConnectionSource.java:66)
10-24 15:15:04.600: E/AndroidRuntime(12057): at com.j256.ormlite.dao.BaseDaoImpl.create(BaseDaoImpl.java:306)
10-24 15:15:04.600: E/AndroidRuntime(12057): at com.mypackage.instagram.UpdateInstagramPhotosService.performUpdate(UpdateInstagramPhotosService.java:85)
10-24 15:15:04.600: E/AndroidRuntime(12057): at com.mypackage.PhotoUpdateService.onHandleIntent(PhotoUpdateService.java:27)
10-24 15:15:04.600: E/AndroidRuntime(12057): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
10-24 15:15:04.600: E/AndroidRuntime(12057): at android.os.Handler.dispatchMessage(Handler.java:99)
10-24 15:15:04.600: E/AndroidRuntime(12057): at android.os.Looper.loop(Looper.java:137)
10-24 15:15:04.600: E/AndroidRuntime(12057): at android.os.HandlerThread.run(HandlerThread.java:60)
10-24 15:15:04.600: E/AndroidRuntime(12057): Caused by: java.lang.ExceptionInInitializerError
10-24 15:15:04.600: E/AndroidRuntime(12057): at com.j256.ormlite.android.AndroidCompiledStatement.<clinit>(AndroidCompiledStatement.java:33)
10-24 15:15:04.600: E/AndroidRuntime(12057): ... 17 more
10-24 15:15:04.600: E/AndroidRuntime(12057): Caused by: java.lang.Error: Unresolved compilation problems:
10-24 15:15:04.600: E/AndroidRuntime(12057): The import android.os.CancellationSignal cannot be resolved
10-24 15:15:04.600: E/AndroidRuntime(12057): CancellationSignal cannot be resolved to a type
10-24 15:15:04.600: E/AndroidRuntime(12057): CancellationSignal cannot be resolved to a type
10-24 15:15:04.600: E/AndroidRuntime(12057): CancellationSignal cannot be resolved to a type
10-24 15:15:04.600: E/AndroidRuntime(12057): CancellationSignal cannot be resolved to a type
10-24 15:15:04.600: E/AndroidRuntime(12057): CancellationSignal cannot be resolved to a type
10-24 15:15:04.600: E/AndroidRuntime(12057): at com.j256.ormlite.android.compat.JellyBeanApiCompatibility.<init>(JellyBeanApiCompatibility.java:5)
10-24 15:15:04.600: E/AndroidRuntime(12057): at com.j256.ormlite.android.compat.ApiCompatibilityUtils.<clinit>(ApiCompatibilityUtils.java:40)
10-24 15:15:04.600: E/AndroidRuntime(12057): ... 18 more
This is happening in an IntentService subclass. Here's some relevant code from that class:
private DatabaseHelper databaseHelper;
static {
OpenHelperManager.setOpenHelperClass(DatabaseHelper.class);
}
public DatabaseHelper getHelper() {
if (databaseHelper == null) {
databaseHelper = OpenHelperManager.getHelper(this, DatabaseHelper.class);
}
return databaseHelper;
}
#Override
public void onDestroy() {
super.onDestroy();
if (databaseHelper != null) {
OpenHelperManager.releaseHelper();
databaseHelper = null;
}
}
I can import android.os.CancellationSignal in my code just fine.
It was happening the same with me, thanks for the help... When rolled back to 4.45, the problem was solved.
Import android.os.CancellationSignal cannot be resolved ORMLite on Android
This was happening on the trunk version of the ORMLite source. 4.48 added the first start of Android compatibility layer which (unfortunately) means that there are classes there that don't compile under earlier versions of Android API.
That said, I had forgotten to upgrade the pom.xml file for the appropriate version of the Android API. The 4.48 release made the following change which should work for you ask well.
<!-- <android-version>2.3.3</android-version> -->
<android-version>4.1.1.4</android-version>
Related
I'm trying to migrate to Materials Theme. The first step is to import Appcompatv7 but when I add the library to my project and run the app this error occurs...
10-24 20:37:11.506: E/AndroidRuntime(13807): FATAL EXCEPTION: main
10-24 20:37:11.506: E/AndroidRuntime(13807): Process: com.ghsoft.teacher, PID: 13807
10-24 20:37:11.506: E/AndroidRuntime(13807): java.lang.NoSuchFieldError: No static field ActionBarWindow of type [I in class Landroid/support/v7/appcompat/R$styleable; or its superclasses (declaration of 'android.support.v7.appcompat.R$styleable' appears in /data/app/com.ghsoft.teacher-1/base.apk)
10-24 20:37:11.506: E/AndroidRuntime(13807): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:106)
10-24 20:37:11.506: E/AndroidRuntime(13807): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57)
10-24 20:37:11.506: E/AndroidRuntime(13807): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:99)
10-24 20:37:11.506: E/AndroidRuntime(13807): at com.ghsoft.teacher.HomeActivity.onCreate(HomeActivity.java:46)
10-24 20:37:11.506: E/AndroidRuntime(13807): at android.app.Activity.performCreate(Activity.java:6018)
10-24 20:37:11.506: E/AndroidRuntime(13807): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
10-24 20:37:11.506: E/AndroidRuntime(13807): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2370)
10-24 20:37:11.506: E/AndroidRuntime(13807): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2480)
10-24 20:37:11.506: E/AndroidRuntime(13807): at android.app.ActivityThread.access$800(ActivityThread.java:151)
10-24 20:37:11.506: E/AndroidRuntime(13807): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1377)
10-24 20:37:11.506: E/AndroidRuntime(13807): at android.os.Handler.dispatchMessage(Handler.java:102)
10-24 20:37:11.506: E/AndroidRuntime(13807): at android.os.Looper.loop(Looper.java:155)
10-24 20:37:11.506: E/AndroidRuntime(13807): at android.app.ActivityThread.main(ActivityThread.java:5725)
10-24 20:37:11.506: E/AndroidRuntime(13807): at java.lang.reflect.Method.invoke(Native Method)
10-24 20:37:11.506: E/AndroidRuntime(13807): at java.lang.reflect.Method.invoke(Method.java:372)
10-24 20:37:11.506: E/AndroidRuntime(13807): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1030)
10-24 20:37:11.506: E/AndroidRuntime(13807): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:825)
I hope you can help me out guys. Thanks
Maybe you should update the appcompat v7 library to latest version.Just try.
I have an activity that has a view pager and loads it's images from a JSON ( and so, several fragments ).
When I do some kind of external activity like start a phonecall or see a website ( via my aplication ), when this activity resumes it gives me a null pointer exception.
10-24 19:36:56.626: E/AndroidRuntime(18567): FATAL EXCEPTION: main
10-24 19:36:56.626: E/AndroidRuntime(18567): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.imagefromurl/com.example.imagefromurl.MainActivity}: java.lang.NullPointerException
10-24 19:36:56.626: E/AndroidRuntime(18567): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2373)
10-24 19:36:56.626: E/AndroidRuntime(18567): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2425)
10-24 19:36:56.626: E/AndroidRuntime(18567): at android.app.ActivityThread.access$600(ActivityThread.java:162)
10-24 19:36:56.626: E/AndroidRuntime(18567): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
10-24 19:36:56.626: E/AndroidRuntime(18567): at android.os.Handler.dispatchMessage(Handler.java:107)
10-24 19:36:56.626: E/AndroidRuntime(18567): at android.os.Looper.loop(Looper.java:194)
10-24 19:36:56.626: E/AndroidRuntime(18567): at android.app.ActivityThread.main(ActivityThread.java:5422)
10-24 19:36:56.626: E/AndroidRuntime(18567): at java.lang.reflect.Method.invokeNative(Native Method)
10-24 19:36:56.626: E/AndroidRuntime(18567): at java.lang.reflect.Method.invoke(Method.java:525)
10-24 19:36:56.626: E/AndroidRuntime(18567): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:837)
10-24 19:36:56.626: E/AndroidRuntime(18567): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)
10-24 19:36:56.626: E/AndroidRuntime(18567): at dalvik.system.NativeStart.main(Native Method)
10-24 19:36:56.626: E/AndroidRuntime(18567): Caused by: java.lang.NullPointerException
10-24 19:36:56.626: E/AndroidRuntime(18567): at com.example.imagefromurl.FragmentOne.onCreateView(FragmentOne.java:28)
10-24 19:36:56.626: E/AndroidRuntime(18567): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1504)
10-24 19:36:56.626: E/AndroidRuntime(18567): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:942)
10-24 19:36:56.626: E/AndroidRuntime(18567): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1121)
10-24 19:36:56.626: E/AndroidRuntime(18567): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1103)
10-24 19:36:56.626: E/AndroidRuntime(18567): at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1901)
10-24 19:36:56.626: E/AndroidRuntime(18567): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:567)
10-24 19:36:56.626: E/AndroidRuntime(18567): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1167)
10-24 19:36:56.626: E/AndroidRuntime(18567): at android.app.Activity.performStart(Activity.java:5132)
10-24 19:36:56.626: E/AndroidRuntime(18567): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2346)
10-24 19:36:56.626: E/AndroidRuntime(18567): ... 11 more
Is the any way that I can solve this?
Line 28: sUrl = activity.urlProfile.toString();
translation - on main activity I run the AsynkTask and I get this string sUrl . then on the fragment I cast the activity and get the string ( probably you would figure that by yourselves but it doesnt hurt to describe it all )
Either the fragment has lost the instance of that activity, so the field activity is null.
Or the the field inside the activity urlProfile is null.
Or you casted your activity into a wrong activity, usually you get the activity with getActivity() or you catch that from the parameters.
But the main problem is, that you try to call toString() on a null which causes the exception. Try to catch it with
if(activity != null && activity.urlProfile != null) {
sUrl = activity.urlProfile.toString();
} else {
// do something different when those objects are null
}
I am getting Facebook ApiException: Invalid Application error when I try to log in with some other account apart from my Developer Account and even my sandbox mode is off as I have checked with other posts having same issue.Thanks in advance.
10-24 17:03:24.355: W/System.err(13721): com.facebook.FacebookAuthorizationException: UnknownError: ApiException:Invalid application 165081033652784
10-24 17:03:24.355: W/System.err(13721): at com.facebook.Session.handleAuthorizationResult(Session.java:1078)
10-24 17:03:24.355: W/System.err(13721): at com.facebook.Session.onActivityResult(Session.java:554)
10-24 17:03:24.355: W/System.err(13721): at com.facebook.UiLifecycleHelper.onActivityResult(UiLifecycleHelper.java:144)
10-24 17:03:24.355: W/System.err(13721): at com.punchh.base.FacebookActivity.onActivityResult(FacebookActivity.java:141)
10-24 17:03:24.355: W/System.err(13721): at android.app.Activity.dispatchActivityResult(Activity.java:5390)
10-24 17:03:24.355: W/System.err(13721): at android.app.ActivityThread.deliverResults(ActivityThread.java:3201)
10-24 17:03:24.355: W/System.err(13721): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3248)
10-24 17:03:24.355: W/System.err(13721): at android.app.ActivityThread.access$1200(ActivityThread.java:140)
10-24 17:03:24.355: W/System.err(13721): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1285)
10-24 17:03:24.355: W/System.err(13721): at android.os.Handler.dispatchMessage(Handler.java:99)
10-24 17:03:24.355: W/System.err(13721): at android.os.Looper.loop(Looper.java:137)
10-24 17:03:24.355: W/System.err(13721): at android.app.ActivityThread.main(ActivityThread.java:4935)
10-24 17:03:24.355: W/System.err(13721): at java.lang.reflect.Method.invokeNative(Native Method)
10-24 17:03:24.355: W/System.err(13721): at java.lang.reflect.Method.invoke(Method.java:511)
10-24 17:03:24.355: W/System.err(13721): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
10-24 17:03:24.355: W/System.err(13721): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
10-24 17:03:24.355: W/System.err(13721): at dalvik.system.NativeStart.main(Native Method)
I had the same problems, check the facebook's application configuration, maybe is on Developer Mode (SandBox). Only developer users added in developer roles can see the app and use it.
Try changing the app configuration to public app.
Take a note: If you set like "Public App" all facebook user will be able to see your app. If your application is in development period it's better work with Facebook Roles. When your app is in release period it is time to change to "Public App"
My app works good in portrait mode. when i use landscape mode and perform any activity it gets force close. The log says null pointer exception. I verified with the source all the information is passing good but getting force close.
Log:
10-24 17:14:38.566: E/AndroidRuntime(3684): FATAL EXCEPTION: main
10-24 17:14:38.566: E/AndroidRuntime(3684): java.lang.RuntimeException: Unable to start activity ComponentInfo{/app.UserPage}: java.lang.NullPointerException
10-24 17:14:38.566: E/AndroidRuntime(3684): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2343)
10-24 17:14:38.566: E/AndroidRuntime(3684): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395)
10-24 17:14:38.566: E/AndroidRuntime(3684): at android.app.ActivityThread.access$600(ActivityThread.java:162)
10-24 17:14:38.566: E/AndroidRuntime(3684): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
10-24 17:14:38.566: E/AndroidRuntime(3684): at android.os.Handler.dispatchMessage(Handler.java:107)
10-24 17:14:38.566: E/AndroidRuntime(3684): at android.os.Looper.loop(Looper.java:194)
10-24 17:14:38.566: E/AndroidRuntime(3684): at android.app.ActivityThread.main(ActivityThread.java:5371)
10-24 17:14:38.566: E/AndroidRuntime(3684): at java.lang.reflect.Method.invokeNative(Native Method)
10-24 17:14:38.566: E/AndroidRuntime(3684): at java.lang.reflect.Method.invoke(Method.java:525)
10-24 17:14:38.566: E/AndroidRuntime(3684): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
10-24 17:14:38.566: E/AndroidRuntime(3684): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
10-24 17:14:38.566: E/AndroidRuntime(3684): at dalvik.system.NativeStart.main(Native Method)
10-24 17:14:38.566: E/AndroidRuntime(3684): Caused by: java.lang.NullPointerException
10-24 17:14:38.566: E/AndroidRuntime(3684): at app.UserPage.onCreate(UserPage.java:219)
10-24 17:14:38.566: E/AndroidRuntime(3684): at android.app.Activity.performCreate(Activity.java:5122)
10-24 17:14:38.566: E/AndroidRuntime(3684): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
10-24 17:14:38.566: E/AndroidRuntime(3684): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
10-24 17:14:38.566: E/AndroidRuntime(3684): ... 11 more
Im working with android, and am releatively new to it, Ive got an exception I cant seem to fix.
Logcat output
10-24 13:50:59.941: E/AndroidRuntime(772): FATAL EXCEPTION: main
10-24 13:50:59.941: E/AndroidRuntime(772): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.metronome/com.metronome.MainActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x78
10-24 13:50:59.941: E/AndroidRuntime(772): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.app.ActivityThread.access$600(ActivityThread.java:122)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.os.Handler.dispatchMessage(Handler.java:99)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.os.Looper.loop(Looper.java:137)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.app.ActivityThread.main(ActivityThread.java:4340)
10-24 13:50:59.941: E/AndroidRuntime(772): at java.lang.reflect.Method.invokeNative(Native Method)
10-24 13:50:59.941: E/AndroidRuntime(772): at java.lang.reflect.Method.invoke(Method.java:511)
10-24 13:50:59.941: E/AndroidRuntime(772): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-24 13:50:59.941: E/AndroidRuntime(772): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-24 13:50:59.941: E/AndroidRuntime(772): at dalvik.system.NativeStart.main(Native Method)
10-24 13:50:59.941: E/AndroidRuntime(772): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x78
10-24 13:50:59.941: E/AndroidRuntime(772): at android.content.res.Resources.getText(Resources.java:247)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.widget.TextView.setText(TextView.java:3432)
10-24 13:50:59.941: E/AndroidRuntime(772): at com.metronome.MainActivity.onCreate(MainActivity.java:36)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.app.Activity.performCreate(Activity.java:4465)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
10-24 13:50:59.941: E/AndroidRuntime(772): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
10-24 13:50:59.941: E/AndroidRuntime(772): ... 11 more
Ive read that people say to fix the problem by cleaning the project but I have tried that twice and it didnt help. I also creted another project and copied the code, so I think it is something different. Any help is appreciated.
Line 36
txtBPM1.setText(120, TextView.BufferType.EDITABLE);
This error occurs when you access some controls or which is not present in your layout you pass on onCreate in you activity setContentView(R.layout.your_layout);. Just checkout all the id's , string's and other controls which you are using belongs to same layout or not
change 120 to be a string like so :
txtBPM1.setText(""+120, TextView.BufferType.EDITABLE);
(your error in MainActivity.java:line 36 (it is import generated R))
1.delete error line from import and use pop-up message on red R.id.**
2. close and reopen IDE