I am trying to build a sample android app for microstream but getting the error.
Gradle Dependencies
dependencies {
implementation 'one.microstream:microstream-storage-embedded:05.00.02-MS-GA'
...
}
Error
Process: com.example.microstream, PID: 6369
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.microstream/com.example.microstream.MainActivity}: one.microstream.persistence.exceptions.PersistenceException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: one.microstream.persistence.exceptions.PersistenceException
at one.microstream.persistence.internal.PersistenceTypeDictionaryFileHandler.writeTypeDictionary(PersistenceTypeDictionaryFileHandler.java:107)
at one.microstream.persistence.internal.PersistenceTypeDictionaryFileHandler.writeTypeDictionary(PersistenceTypeDictionaryFileHandler.java:203)
at one.microstream.persistence.internal.PersistenceTypeDictionaryFileHandler.storeTypeDictionary(PersistenceTypeDictionaryFileHandler.java:209)
at one.microstream.persistence.types.PersistenceTypeDictionaryExporter$Default.exportTypeDictionary(PersistenceTypeDictionaryExporter.java:93)
at one.microstream.persistence.types.PersistenceTypeDictionaryManager$Exporting.exportTypeDictionary(PersistenceTypeDictionaryManager.java:267)
at one.microstream.persistence.types.PersistenceTypeDictionaryManager$Exporting.synchUpdateExport(PersistenceTypeDictionaryManager.java:258)
at one.microstream.persistence.types.PersistenceTypeDictionaryManager$Exporting.registerRuntimeTypeDefinitions(PersistenceTypeDictionaryManager.java:324)
at one.microstream.persistence.types.PersistenceTypeHandlerManager$Default.synchUnvalidatedRegisterTypeHandlers(PersistenceTypeHandlerManager.java:662)
at one.microstream.persistence.types.PersistenceTypeHandlerManager$Default.registerTypeHandlers(PersistenceTypeHandlerManager.java:644)
at one.microstream.persistence.types.PersistenceTypeHandlerManager$Default.initialRegisterTypeHandlers(PersistenceTypeHandlerManager.java:687)
at one.microstream.persistence.types.PersistenceTypeHandlerManager$Default.synchInternalInitialize(PersistenceTypeHandlerManager.java:968)
at one.microstream.persistence.types.PersistenceTypeHandlerManager$Default.initialize(PersistenceTypeHandlerManager.java:941)
at one.microstream.storage.embedded.types.EmbeddedStorageFoundation$Default.createEmbeddedStorageManager(EmbeddedStorageFoundation.java:791)
at one.microstream.storage.embedded.types.EmbeddedStorage.createAndStartStorageManager(EmbeddedStorage.java:649)
at one.microstream.storage.embedded.types.EmbeddedStorage.start(EmbeddedStorage.java:467)
at one.microstream.storage.embedded.types.EmbeddedStorage.start(EmbeddedStorage.java:317)
at com.example.microstream.MainActivity.microstreamStorageManager(MainActivity.kt:52)
at com.example.microstream.MainActivity.checkPermission(MainActivity.kt:78)
at com.example.microstream.MainActivity.onCreate(MainActivity.kt:47)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: one.microstream.exceptions.IORuntimeException: java.nio.file.AccessDeniedException: storage/PersistenceTypeDictionary.ptd
2021-10-20 07:26:34.758 6369-6369/com.example.microstream E/AndroidRuntime: at one.microstream.afs.nio.types.NioIoHandler$Default.specificCreate(NioIoHandler.java:324)
at one.microstream.afs.nio.types.NioIoHandler$Default.specificCreate(NioIoHandler.java:1)
at one.microstream.afs.types.AIoHandler$Abstract.create(AIoHandler.java:701)
at one.microstream.afs.types.AWritableFile.create(AWritableFile.java:102)
at one.microstream.persistence.internal.PersistenceTypeDictionaryFileHandler.writeTypeDictionary(PersistenceTypeDictionaryFileHandler.java:91)
... 33 more
Caused by: java.nio.file.AccessDeniedException: storage/PersistenceTypeDictionary.ptd
at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.createFile(Files.java:632)
at one.microstream.afs.nio.types.NioIoHandler$Default.specificCreate(NioIoHandler.java:320)
... 37 more
How to resolve this issue?
The problem is described in the log. You are trying to write to a location where the application cannot store data.
To get the path for writing data, you can use for example:
Context instrumentationContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
targetDirectory = instrumentationContext.getFilesDir().toPath();
targetDirectory = targetDirectory.resolve("storage");
targetDirectory.toFile().mkdir();
and after that:
EmbeddedStorageManager storage = EmbeddedStorage.start(root, targetDirectory);
I go to activity from two fragment and i pass extras through intent the first intent is data
Intent intent = new Intent(getContext(), AllAlbumImgActivity.class);
photoGrapherSavedPhoto.albumName=getResources().getString(R.string.photos);
intent.putExtra(SELECTED_IMG_ID, photoGrapherSavedPhoto.id);
intent.putExtra(LIST_NAME, getActivity().getResources().getString(R.string.photos));
intent.putExtra(LIST_TYPE, CURRENT_PHOTOGRAPHER_PHOTOS_LIST);
intent.putExtra(CURRENT_PAGE, nextPageUrl);
intent.putParcelableArrayListExtra(ALL_ALBUM_IMAGES, (ArrayList<? extends Parcelable>) photoGrapherPhotoList);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivityForResult(intent, ALBUM_LIST_REQUEST_CODE);
and it worked fine
the second intent
Intent intent = new Intent(getContext(), AllAlbumImgActivity.class);
photoGrapherSavedPhoto.albumName="Saved";
intent.putExtra(SELECTED_IMG_ID, photoGrapherSavedPhoto.id);
intent.putExtra(LIST_NAME, getActivity().getResources().getString(R.string.saved));
intent.putExtra(LIST_TYPE, CURRENT_PHOTOGRAPHER_SAVED_LIST);
intent.putExtra(CURRENT_PAGE, nextPageUrl);
intent.putParcelableArrayListExtra(ALL_ALBUM_IMAGES, (ArrayList<? extends Parcelable>) photoGrapherSavedPhotoList);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivityForResult(intent, ALBUM_LIST_REQUEST_CODE);
but it doesn't work fine with second intent data
here is how i receive the data
if (intent.getSerializableExtra(LIST_TYPE) != null)
photosListType = (Constants.PhotosListType) intent.getSerializableExtra(LIST_TYPE);
if (intent.getStringExtra(LIST_NAME) != null)
topBarTitle.setText(intent.getStringExtra(LIST_NAME));
if (photosListType == CURRENT_PHOTOGRAPHER_PHOTOS_LIST || photosListType == CURRENT_PHOTOGRAPHER_SAVED_LIST) {
nextPageUrl = intent.getStringExtra(CURRENT_PAGE);
}
if (intent.getParcelableArrayListExtra(ALL_ALBUM_IMAGES) != null) {
this.albumImgList = intent.getParcelableArrayListExtra(ALL_ALBUM_IMAGES);
int selectedPosition = intent.getIntExtra(SELECTED_IMG_ID, 0);
for (int i = 0; i < albumImgList.size(); i++) {
if (albumImgList.get(i).id == selectedPosition) {
// Objects.requireNonNull(allAlbumImgRv.getLayoutManager()).smoothScrollToPosition(allAlbumImgRv, null, i);
scrolledPosition = i;
break;
}
}
}
but when i pass the second intent it shows this error
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.softmills.phlog, PID: 14899
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.softmills.phlog/com.example.softmills.phlog.ui.album.view.AllAlbumImgActivity}: java.lang.RuntimeException: Parcel android.os.Parcel#b21b847: Unmarshalling unknown type code 7274595 at offset 1100
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.RuntimeException: Parcel android.os.Parcel#b21b847: Unmarshalling unknown type code 7274595 at offset 1100
at android.os.Parcel.readValue(Parcel.java:2747)
at android.os.Parcel.readListInternal(Parcel.java:3098)
at android.os.Parcel.readArrayList(Parcel.java:2319)
at android.os.Parcel.readValue(Parcel.java:2689)
at android.os.Parcel.readArrayMapInternal(Parcel.java:3037)
at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:288)
at android.os.BaseBundle.unparcel(BaseBundle.java:232)
at android.os.BaseBundle.getSerializable(BaseBundle.java:1227)
at android.os.Bundle.getSerializable(Bundle.java:1034)
at android.content.Intent.getSerializableExtra(Intent.java:7516)
at com.example.softmills.phlog.ui.album.view.AllAlbumImgActivity.initView(AllAlbumImgActivity.java:97)
at com.example.softmills.phlog.ui.album.view.AllAlbumImgActivity.onCreate(AllAlbumImgActivity.java:85)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
there i was passing All album as parceable and in the two intent it has the same object
but one work and one generate strange error related to parcelable!!
You can trying this one :
#Parcel
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}
Add this to proguard , it can be help u.
I am developing an Android app using Kotlin. I am trying to understand how Dagger 2 works to perform dependency injection. I am very new to Dagger 2. I am following this tutorial,https://medium.com/#elye.project/dagger-2-for-dummies-in-kotlin-with-one-page-simple-code-project-618a5f9f2fe8 to understand how it works and applying it to my project too. But I am getting an error. Following is what I have done so far.
I created an interface called AppComponent with the following code
package com.example.utils
import com.example.memento.LoginActivity
import dagger.Component
#Component
interface AppComponent
{
fun inject(app: LoginActivity)
}
I also created a class called AuthService with the following code.
package com.example.services
import javax.inject.Inject
class AuthService #Inject constructor()
{
public fun login(): String
{
return "I am logged in";
}
}
This is my LoginActivity class
class LoginActivity : AppCompatActivity()
{
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
val authService = DaggerAppComponent.create().inject(this) as AuthService
tv_testing.text = authService.login();
}
}
When I run my app, I get the following error
java.lang.ClassCastException: kotlin.Unit cannot be cast to com.example.services.AuthService
at com.example.memento.LoginActivity.onCreate(LoginActivity.kt:25)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:674)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/MonitoringInstr: Exception encountered by: com.example.memento.LoginActivity#39cc00e. Dumping thread state to outputs and pining for the fjords.
java.lang.ClassCastException: kotlin.Unit cannot be cast to com.example.services.AuthService
at com.example.memento.LoginActivity.onCreate(LoginActivity.kt:25)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:674)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/THREAD_STATE: Thread[MonitoringInstrumentation,5,main]
java.lang.Object.wait(Native Method)
android.app.Instrumentation.startActivitySync(Instrumentation.java:496)
android.app.Instrumentation.startActivitySync(Instrumentation.java:435)
androidx.test.runner.MonitoringInstrumentation.access$101(MonitoringInstrumentation.java:98)
androidx.test.runner.MonitoringInstrumentation$4.call(MonitoringInstrumentation.java:443)
androidx.test.runner.MonitoringInstrumentation$4.call(MonitoringInstrumentation.java:440)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
java.lang.Thread.run(Thread.java:764)
Thread[Binder:11719_2,5,main]
Thread[magnifier pixel copy result handler,5,main]
android.os.MessageQueue.nativePollOnce(Native Method)
android.os.MessageQueue.next(MessageQueue.java:326)
android.os.Looper.loop(Looper.java:160)
android.os.HandlerThread.run(HandlerThread.java:65)
Thread[FinalizerWatchdogDaemon,5,system]
java.lang.Object.wait(Native Method)
java.lang.Daemons$FinalizerWatchdogDaemon.sleepUntilNeeded(Daemons.java:297)
java.lang.Daemons$FinalizerWatchdogDaemon.runInternal(Daemons.java:277)
java.lang.Daemons$Daemon.run(Daemons.java:103)
java.lang.Thread.run(Thread.java:764)
Thread[InstrumentationConnectionThread,5,main]
android.os.MessageQueue.nativePollOnce(Native Method)
android.os.MessageQueue.next(MessageQueue.java:326)
android.os.Looper.loop(Looper.java:160)
android.os.HandlerThread.run(HandlerThread.java:65)
Thread[Profile Saver,5,system]
Thread[main,5,main]
dalvik.system.VMStack.getThreadStackTrace(Native Method)
java.lang.Thread.getStackTrace(Thread.java:1538)
java.lang.Thread.getAllStackTraces(Thread.java:1588)
androidx.test.runner.MonitoringInstrumentation.getThreadState(MonitoringInstrumentation.java:643)
androidx.test.runner.MonitoringInstrumentation.dumpThreadStateToOutputs(MonitoringInstrumentation.java:638)
androidx.test.runner.MonitoringInstrumentation.onException(MonitoringInstrumentation.java:632)
androidx.test.runner.AndroidJUnitRunner.onException(AndroidJUnitRunner.java:522)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
android.os.Handler.dispatchMessage(Handler.java:106)
android.os.Looper.loop(Looper.java:193)
android.app.ActivityThread.main(ActivityThread.java:6669)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Thread[Binder:11719_1,5,main]
Thread[ReferenceQueueDaemon,5,system]
java.lang.Object.wait(Native Method)
java.lang.Daemons$ReferenceQueueDaemon.runInternal(Daemons.java:178)
java.lang.Daemons$Daemon.run(Daemons.java:103)
java.lang.Thread.run(Thread.java:764)
Thread[Jit thread pool worker thread 0,5,main]
Thread[FinalizerDaemon,5,system]
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:422)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:188)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:209)
java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:232)
java.lang.Daemons$Daemon.run(Daemons.java:103)
java.lang.Thread.run(Thread.java:764)
Thread[HeapTaskDaemon,5,system]
Thread[Instr: com.example.memento.MockTestRunner,5,main]
java.lang.Object.w
E/MonitoringInstr: Dying now...
D/AndroidRuntime: Shutting down VM
--------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.memento, PID: 11719
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.memento/com.example.memento.LoginActivity}: java.lang.ClassCastException: kotlin.Unit cannot be cast to com.example.services.AuthService
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassCastException: kotlin.Unit cannot be cast to com.example.services.AuthService
at com.example.memento.LoginActivity.onCreate(LoginActivity.kt:25)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:674)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/MonitoringInstr: Exception encountered by: Thread[main,5,main]. Dumping thread state to outputs and pining for the fjords.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.memento/com.example.memento.LoginActivity}: java.lang.ClassCastException: kotlin.Unit cannot be cast to com.example.services.AuthService
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassCastException: kotlin.Unit cannot be cast to com.example.services.AuthService
at com.example.memento.LoginActivity.onCreate(LoginActivity.kt:25)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:674)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/THREAD_STATE: Thread[MonitoringInstrumentation,5,main]
java.lang.Object.wait(Native Method)
android.app.Instrumentation.startActivitySync(Instrumentation.java:496)
android.app.Instrumentation.startActivitySync(Instrumentation.java:435)
androidx.test.runner.MonitoringInstrumentation.access$101(MonitoringInstrumentation.java:98)
androidx.test.runner.MonitoringInstrumentation$4.call(MonitoringInstrumentation.java:443)
androidx.test.runner.MonitoringInstrumentation$4.call(MonitoringInstrumentation.java:440)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
java.lang.Thread.run(Thread.java:764)
Thread[Binder:11719_2,5,main]
Thread[magnifier pixel copy result handler,5,main]
android.os.MessageQueue.nativePollOnce(Native Method)
android.os.MessageQueue.next(MessageQueue.java:326)
android.os.Looper.loop(Looper.java:160)
android.os.HandlerThread.run(HandlerThread.java:65)
Thread[FinalizerWatchdogDaemon,5,system]
java.lang.Object.wait(Native Method)
java.lang.Daemons$FinalizerWatchdogDaemon.sleepUntilNeeded(Daemons.java:297)
java.lang.Daemons$FinalizerWatchdogDaemon.runInternal(Daemons.java:277)
java.lang.Daemons$Daemon.run(Daemons.java:103)
java.lang.Thread.run(Thread.java:764)
Thread[InstrumentationConnectionThread,5,main]
android.os.MessageQueue.nativePollOnce(Native Method)
android.os.MessageQueue.next(MessageQueue.java:326)
android.os.Looper.loop(Looper.java:160)
android.os.HandlerThread.run(HandlerThread.java:65)
Thread[Profile Saver,5,system]
Thread[main,5,main]
dalvik.system.VMStack.getThreadStackTrace(Native Method)
java.lang.Thread.getStackTrace(Thread.java:1538)
java.lang.Thread.getAllStackTraces(Thread.java:1588)
androidx.test.runner.MonitoringInstrumentation.getThreadState(MonitoringInstrumentation.java:643)
androidx.test.runner.MonitoringInstrumentation.dumpThreadStateToOutputs(MonitoringInstrumentation.java:638)
androidx.test.runner.MonitoringInstrumentation.onException(MonitoringInstrumentation.java:632)
androidx.test.runner.AndroidJUnitRunner.onException(AndroidJUnitRunner.java:522)
androidx.test.runner.MonitoringInstrumentation$3.uncaughtException(MonitoringInstrumentation.java:268)
java.lang.Thread.dispatchUncaughtException(Thread.java:1955)
Thread[Binder:11719_1,5,main]
Thread[ReferenceQueueDaemon,5,system]
java.lang.Object.wait(Native Method)
java.lang.Daemons$ReferenceQueueDaemon.runInternal(Daemons.java:178)
java.lang.Daemons$Daemon.run(Daemons.java:103)
java.lang.Thread.run(Thread.java:764)
Thread[Jit thread pool worker thread 0,5,main]
Thread[FinalizerDaemon,5,system]
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:422)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:188)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:209)
java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:232)
java.lang.Daemons$Daemon.run(Daemons.java:103)
java.lang.Thread.run(Thread.java:764)
Thread[HeapTaskDaemon,5,system]
Thread[Instr: com.example.memento.MockTestRunner,5,main]
java.lang.Object.wait(Native Method)
java.lang.Thread.parkFor$(Thread.java:2137)
sun.misc.Unsafe.park(Unsafe.java:358)
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230)
java.util.concurrent.FutureTask.awaitDone(FutureTask.java:447)
java.util.concurrent.FutureTask.get(FutureTask.java:205)
androidx.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:448)
androidx.test.rule.ActivityTestRule.launchActivity(ActivityTestRule.java:354)
androidx.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:525)
org.junit.rules.RunRules.evaluate(RunRules.java:20)
org.junit.runners.ParentRunner.runLeaf(ParentRunner
E/MonitoringInstr: Dying now...
W/MonitoringInstr: Invoking uncaught exception handler java.lang.ThreadGroup[name=main,maxpri=10] (a class java.lang.ThreadGroup)
I/Process: Sending signal. PID: 11719 SIG: 9
Test running failed: Instrumentation run failed due to 'Process crashed.'
What is wrong with my code?
I tried updating the LoginActivity to this
class LoginActivity : AppCompatActivity()
{
lateinit var authService: AuthService
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
DaggerAppComponent.create().inject(this)
tv_testing.text = authService.login()
}
}
Then I got this error
kotlin.UninitializedPropertyAccessException: lateinit property authService has not been initialized
at com.example.memento.LoginActivity.onCreate(LoginActivity.kt:27)
DaggerAppComponent.create().inject(this) doesn't return anything but you're trying to cast it to AuthService. Therefore, you get ClassCastException. Instead, you should first declare AuthService as lateinit var and annotate it with #Inject. Then you can call inject() function. You can see full code below:
class LoginActivity : AppCompatActivity()
{
#Inject
private lateinit var authService: AuthService
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
DaggerAppComponent.create().inject(this)
tv_testing.text = authService.login();
}
}
I hope my answer helps.
Trying to use parse server with AWS
I have tried several tutorials seems like I am missing somehing simple just don't know what it is
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.davidavila.myapplication, PID: 6492
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.davidavila.myapplication/com.example.davidavila.myapplication.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File com.parse.ParsePlugins.getParseDir()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File com.parse.ParsePlugins.getParseDir()' on a null object reference
at com.parse.ParseCorePlugins.getCurrentInstallationController(ParseCorePlugins.java:267)
at com.parse.ParseInstallation.getCurrentInstallationController(ParseInstallation.java:56)
at com.parse.ParseInstallation.getCurrentInstallation(ParseInstallation.java:62)
at com.example.davidavila.myapplication.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/Process: Sending signal. PID: 6492 SIG: 9
package com.example.davidavila.myapplication;
import com.parse.Parse;
import com.parse.ParseInstallation;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ParseInstallation.getCurrentInstallation().saveInBackground();
Parse.enableLocalDatastore(this);
Parse.initialize (new Parse.Configuration.Builder(this)
.applicationId("1b5f82b054262c169a8bcc4b5a1f379cbac8bfd5")
.clientKey("f9f3b809dbada7fb5ed7793630e21893fb80fea3")
.server("http://13.58.197.143:80/parse/")
.build()
);
}
public void buttonMain (View view) {
Intent intent = new Intent(this, landingPage.class);
startActivity(intent);
}
}
Expect not to have an issue
Please try as follows
Parse.enableLocalDatastore(MainActivity.this);
Parse.initialize(new Parse.Configuration.Builder(MainActivity.this)
.applicationId("1b5f82b054262c169a8bcc4b5a1f379cbac8bfd5")
.clientKey("f9f3b809dbada7fb5ed7793630e21893fb80fea3")
.server("http://13.58.197.143:80/parse/")
.enableLocalDataStore()
.build());
I'm creating all the objects after onCreate and setContentView but I'm still getting the error [Fatal Error: Main] and it makes my app crash. I've seen people face the same problem but it's when they make objects for their EditText above the setContentView tag and I've tried moving it around but it's just not working for me hope you can help me. I'll provide you guys with the code... Thanks
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//-----------------------------------------------------------------------------------------------------------------------
//ASSIGNING
final EditText name=(findViewById(R.id.editText));
final EditText date=(findViewById(R.id.editText3));
EditText month=(findViewById(R.id.editText4));
final EditText year=(findViewById(R.id.editText5));
Button b=(findViewById(R.id.button));
//-----------------------------------------------------------------------------------------------------------------------
//NAME NUMBER
String s= name.getText().toString();
char[] n=s.toCharArray();
int i,total=0;
The Error I'm getting:-
2019-02-09 13:24:08.085 6934-6934/com.example.numerologysolutions E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.numerologysolutions, PID: 6934
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.numerologysolutions/com.example.numerologysolutions.MainActivity}: java.lang.NumberFormatException: For input string: ""
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.NumberFormatException: For input string: ""
at java.lang.Integer.parseInt(Integer.java:627)
at java.lang.Integer.parseInt(Integer.java:650)
at com.example.numerologysolutions.MainActivity.onCreate(MainActivity.java:81)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
That's the problem according to your error stack trace. You're trying to convert a string to a number.
Caused by: java.lang.NumberFormatException: For input string: ""