Activity is not assignable to Activity - java

I have read several posts for the last couple of days and i can not seem to figure out what my issue is. I have checked the Activity names and they are the same. I have also checked my manifest and I have the . in front of the activities as well.
Here is my logcat file:
02-23 16:48:22.438 1508-1508/com.pctoolman.planme.app E/AndroidRuntime﹕ FATAL
EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.pctoolman.planme.app/com.pctoolman.planme.app.PlanMeMainActivity}:
java.lang.ClassCastException: com.pctoolman.planme.app.PlanMeMainActivity cannot be
cast
to android.app.Activity
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: com.pctoolman.planme.app.PlanMeMainActivity
cannot
be cast to android.app.Activity
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pctoolman.planme.app" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.pctoolman.planme.app.PlanMeMainActivity"
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="com.pctoolman.planme.app.NewEventSetupActivity"
android:label="#string/setup">
</activity>
</application>
PlanMeMainFragment.java
package com.pctoolman.planme.app;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
public class PlanMeMainFragment extends Fragment {
private Button mNewButton, mExistingButton;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.planme_main_fragment, parent, false);
mNewButton = (Button)v.findViewById(R.id.new_event_button);
mNewButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent myIntent = new Intent(getActivity(), NewEventSetupActivity.class);
getActivity().startActivity(myIntent);
}
});
return v;
}
}
PlanMeMainActivity.java
package com.pctoolman.planme.app;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
public class PlanMeMainActivity extends Fragment {
public Fragment createFragment() {
return new PlanMeMainFragment();
}
}

Change this line
public class PlanMeMainActivity extends Fragment {
to
public class PlanMeMainActivity extends FragmentActivity {
Here you can find all that you need to know about Activities and even more. Cheers

Where are you wrong?
<activity
android:name="com.pctoolman.planme.app.PlanMeMainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Why are you wrong?
The mistake is that you added the Fragment in the Manifest as
Activity. However Fragments are not activities
What you should do?
You should add the fragment in an activity and then define that activity in the
Manifest

Your PlanMeMainActivity isn't an Activity; it's a Fragment. Your activity needs to be an activity, and you can then add fragments to it.

Clean Project solved this error. The root cause of the error in my case was different, but I got the same "Activity is not assignable to Activity" error.
I faced this problem after copying existing (perfectly working) Android Project to create a new one.
After copying the project, the AppCompatActivity was not recognized causing all the activities in the Android Manifest file to show the error "activity-is-not-assignable-to-activity".
Which was solved by cleaning the project.

Your PlanMainActivity extends a Fragment. A fragment cannot be cast to an activity

Finally, I find out the solution is add following line in your dependencies:
compile 'com.android.support:support-v4:23.2.0'

just delete ".gradle" folder of your project
and press sync button .
its solved my problem

In my case the error was occurred by just installed plugin in Android Studio. So check your plugins and uninstall odd ones.

My problem was solved by Invalidating Caches and Restarting after having Cleaned the Project.

Related

Webview loadurl crashing

When trying to load a url in my Android Things webview the page initially loads, then crashes the UI with an error message pointing towards the IoT FrameworkPackageStubs.
I am using a Raspberry Pi on Dev Preview 5.1 which supports Webviews and OpenGL but have no idea why my very simple application seems to be crashing. The code for it is as follows
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webView = (WebView) findViewById(R.id.webView);
if(webView != null)
webView.loadUrl("https://www.facebook.com");
}
Here is my manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.airborneathletics.videohwtest">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<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">
<uses-library android:name="com.google.android.things" android:required="false"/>
<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 my Gradle depdencies
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
provided 'com.google.android.things:androidthings:0.5.1-devpreview'
}
And finally my error message I'm receiving when making the calls.
--------- beginning of crash
08-31 20:30:33.458 10146-10146/com.google.android.iot.frameworkpackagestubs E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.google.android.iot.frameworkpackagestubs, PID: 10146
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.google.android.iot.frameworkpackagestubs/com.google.android.iot.frameworkpackagestubs.Stubs$BrowserStub}: java.lang.ClassNotFoundException: Didn't find class "com.google.android.iot.frameworkpackagestubs.Stubs$BrowserStub" on path: DexPathList[[zip file "/system/app/IoTFrameworkPackageStubs/IoTFrameworkPackageStubs.apk"],nativeLibraryDirectories=[/system/app/IoTFrameworkPackageStubs/lib/arm, /system/lib, /system/vendor/lib, /system/lib, /system/vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2718)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.iot.frameworkpackagestubs.Stubs$BrowserStub" on path: DexPathList[[zip file "/system/app/IoTFrameworkPackageStubs/IoTFrameworkPackageStubs.apk"],nativeLibraryDirectories=[/system/app/IoTFrameworkPackageStubs/lib/arm, /system/lib, /system/vendor/lib, /system/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1173)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6541) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 
I will admit some websites do work, but when I go to https://www.google.com and type in a search it crashes with the same message.
Thanks for the assistance.
You're likely running into the same problem as here.
When links are loaded in Android, by default the system will try to launch an application to handle the URL, in this case a browser. However Android Things does not include a browser by default, so it fails to handle the URL and crashes.
You can override this default behavior and have the URLs load in your app's WebView, by setting the WebViewClient in your app before loading any URLs:
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.setWebViewClient(new WebViewClient());
This is documented here.
If you have a web view along with a progress bar, then the code is down below:
WebView myWebView = (WebView) findViewById(R.id.webView3);
progressDialog = new ProgressDialog(YOUR_ACTIVITY.this);
progressDialog.setCancelable(true);
progressDialog.setMessage("Please wait....");
progressDialog.show();
myWebView.setWebViewClient(new WebViewClient() { // setting Progress Bar
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
Log.d(TAG, "LOADING");
return true;
}
#Override
public void onPageFinished(WebView view, String url) {
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
}
});
myWebView.setInitialScale(1);
myWebView.getSettings().setLoadWithOverviewMode(true);
myWebView.getSettings().setUseWideViewPort(true);
myWebView.getSettings().setJavaScriptEnabled(true);myWebView.loadUrl("https://www.google.com");
myWebView.getSettings().setSupportZoom(true);
myWebView.getSettings().setBuiltInZoomControls(true);
myWebView.getSettings().setDisplayZoomControls(false);

Android WebView app crashing in emulator: null Application Context?

I'm developing a very simple Android app on a Mac in AndroidStudio and I've created an AVD based on the Nexus S. The app compiles with no issues, the emulator launches and then I get errors in logcat and the app crashes. In the emulator, an error dialog displays with the message "Unfortunately App has stopped"
Here's the logcat output (error level):
10-01 13:59:27.813 14114-14114/com.company.app E/SysUtils﹕ ApplicationContext is null in ApplicationStatus
10-01 13:59:27.832 14114-14114/com.company.app E/libEGL﹕ validate_display:255 error 3008 (EGL_BAD_DISPLAY)
10-01 13:59:27.832 14114-14114/com.company.app E/libEGL﹕ validate_display:255 error 3008 (EGL_BAD_DISPLAY)
10-01 13:59:27.832 14114-14114/com.company.app E/chromium﹕ [ERROR:gl_surface_egl.cc(327)] No suitable EGL configs found.
10-01 13:59:27.832 14114-14114/com.company.app E/chromium﹕ [ERROR:gl_surface_android.cc(23)] GLSurfaceEGL::InitializeOneOff failed.
10-01 13:59:27.832 14114-14114/com.company.app E/chromium﹕ [ERROR:browser_main_loop.cc(698)] GLSurface::InitializeOneOff failed
10-01 13:59:27.854 14114-14114/com.company.app E/DataReductionProxySettingListener﹕ No DRP key due to exception:java.lang.ClassNotFoundException: com.android.webview.chromium.Drp
10-01 13:59:28.530 14114-14165/com.company.app A/chromium﹕ [FATAL:gl_surface_android.cc(58)] Check failed: kGLImplementationNone != GetGLImplementation() (0 vs. 0)
10-01 13:59:28.530 14114-14165/com.company.app A/libc﹕ Fatal signal 6 (SIGABRT), code -6 in tid 14165 (GpuThread)
I'm assuming that the first error related to ApplicationContext is the cause of the other errors, but I'm not sure about that. I've tried about 10 different methods for setting context, but the ApplicationContext error persists.
My main questions: Is the ApplicationContext error the root cause of the crash? If not, what is? What might I try to fix it?
Here's the complete application code for reference:
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.app" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<uses-permission android:name="android.permission.INTERNET" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
MainActivity.java
package com.company.app;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebSettings;
public class MainActivity extends AppCompatActivity {
private String appUrl = "http://company.com/mobile/index.php";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView myWebView = (WebView) findViewById(R.id.webView);
myWebView.setWebViewClient(new MyWebViewClient());
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.loadUrl(appUrl);
}
}
MyWebViewClient.java
package com.company.app;
import android.content.Intent;
import android.net.Uri;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MyWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (Uri.parse(url).getHost().equals("company.com")) {
return false;
}
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
view.getContext().startActivity(intent);
return true;
}
}
Here's the logcat output
That is not a Java stack trace, and therefore is not what you're looking for.
I'm assuming that the first error related to ApplicationContext is the cause of the other errors, but I'm not sure about that
That is some spurious message that you will see, even from apps that run fine.
If not, what is?
As ozbek notes, your <uses-permission> element needs to be moved outside of <application> and made a direct child of <manifest>. Your Java stack trace should mention a missing INTERNET permission.
It is possible that there are other problems, but that's definitely one.

Android cannot start Activity - java.lang.RuntimeException: Unable to start activity ComponentInfo

Here's a problem that's really getting to me, whenever I try to launch my application's main activity, I get the error in LogCat:
java.lang.RuntimeException: Unable to start activity ComponentInfo{me.kworden.atic/me.kworden.atic.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f0c00a9
The stack trace says that the problem is my super.onCreate(savedInstanceState) in my onCreate() method, which is frustrating me, because I can't control the superclass method.
The content layout I'm using is only a LinearLayout, so I don't think it is necessary for you all to see my xml file, although I will post on request.
I've seen the other similar problems on SO, but the only answers were "Clean/Rebuild the project" which hasn't done anything for me. I'm using Android Studio ver. 1.1.0 if this is a known problem, but I haven't seen any known bugs.
Here is my MainActivity, I've stripped out most of the code in order to pinpoint the problem, but now it seems that super.onCreate is the culprit; despite being extremely barebones, my app still fails to even start (i.e. I get "Unfortunately, app has stopped.").
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity
{
#Override
protected void onCreate(Bundle savedInstanceState)
{
// Create the activity and set the main content view //
super.onCreate(savedInstanceState); // This is line 17, per the stack trace //
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the main menu to the toolbar //
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item)
{
int id = item.getItemId();
if(id == R.id.action_settings)
{
return true;
}
return super.onOptionsItemSelected(item);
}
}
Here is my full stack trace:
03-16 23:16:33.572 1494-1494/me.kworden.atic E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: me.kworden.atic, PID: 1494
java.lang.RuntimeException: Unable to start activity ComponentInfo{me.kworden.atic/me.kworden.atic.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f0c00a9
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f0c00a9
at android.content.res.Resources.getValue(Resources.java:1233)
at android.content.res.Resources.getDrawable(Resources.java:756)
at android.content.Context.getDrawable(Context.java:402)
at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3514)
at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3561)
at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1916)
at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:151)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
at me.kworden.atic.MainActivity.onCreate(MainActivity.java:17)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
If anyone stumbles on this in the future I want to make sure that you can get an answer...
The problem was that certain tags that are available only to Material and Android 5.0+ were being used in my styles. So I instead made a res/values-v21/styles.xml folder and put my appropriate settings in there. That fixed the issue.
Remove setContentView(R.layout.activity_main); method
after removing this method if it run successfully then your layout id cannot be gernerated.
and also make sure that your layout id is generated or not in R.java file
open manifest file check application package and activity. that is included or not included in file and also check style of application
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="yourapplicationpackage" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<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>
</application>
</manifest>
If you using tag <view> on xml file just change tag <view> to <View>

Unable to instantiate application error which extends Application class

The below error occurs sometimes for some users.
I haven't seen it through android phones which I have for testing, but I got this crush via Google developer console.
[Error]
java.lang.RuntimeException: Unable to instantiate application com.***.***.MyApplication: java.lang.ClassNotFoundException: com.***.***.MyApplication
at android.app.LoadedApk.makeApplication(LoadedApk.java:501)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4253)
at android.app.ActivityThread.access$1400(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1301)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4950)
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:997)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:764)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.***.***.MyApplication
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newApplication(Instrumentation.java:982)
at android.app.LoadedApk.makeApplication(LoadedApk.java:496)
... 11 more
[MyApplication.java]
public class MyApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
...
}
#Override
public void onTerminate() {
super.onTerminate();
}
...
}
[manifest.xml]
...
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
...
<application
android:name="com.***.***.MyApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
I've tried to find out to solve this problem.
I doubt it might be due to external SD card problem or 'public constructor'.
Because even I do not know how to reenact the situation, I can't be sure whether this is due to SD card or public constructor stuff.
I'm sure there's somebody who got this error and already know how to solve this.
Thus, please help me know what's wrong and how I can fix it.
Thanks.
add your class name in your manifest file. hope this solve your problem
<application android:icon="#drawable/icon" android:label="#string/app_name"
android:name=".MyApplication">
........
for further reading , how to extends Application class, read here.

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo - NFC access

I have seen a number of questions similar to this one, but they seem to be specific to the classes and packages that they use. I tried some of the solutions, but did not help me. I get the following error:
03-27 14:30:08.604: D/AndroidRuntime(8057): Shutting down VM
03-27 14:30:08.604: W/dalvikvm(8057): threadid=1: thread exiting with uncaught exception (group=0x41c02c80)
03-27 14:30:08.604: E/AndroidRuntime(8057): FATAL EXCEPTION: main
03-27 14:30:08.604: E/AndroidRuntime(8057): Process: org.nick.nfc.seaccess, PID: 8057
03-27 14:30:08.604: E/AndroidRuntime(8057): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.nick.nfc.seaccess/org.nick.nfc.seaccess.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "org.nick.nfc.seaccess.MainActivity" on path: DexPathList[[zip file "/system/framework/com.android.nfc_extras.jar", zip file
Any idea, how I should address it?
Here is the beginning of the main activity:
public class MainActivity extends Activity implements OnClickListener {
private static final String TAG = MainActivity.class.getSimpleName();
private Button gpInfoButton;
private Button emvInfoButton;
private Button walletInfoButton;
private TextView infoText;
private Terminal terminal;
private CardConnection seConn;
#Override
public void onCreate(Bundle savedInstanceState) {
...
Here is my activity tag from my manifest. I have seem sometimes folks add the full package name to the manifest. Shall I do this and see what happens?
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|s mallestScreenSize"
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>
I found a link that states the issue may be with how I have edited an xml file, which holds certificates. I have pasted the file below; removed the certs. Do you see any issue with it?
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Applications granted NFCEE access on user builds
See packages/apps/Nfc/etc/sample_nfcee_access.xml for full documentation.
-->
<!-- Google wallet release signature -->
<signer android:signature="308205bd852e" />
<!-- Sequent Wallet signature -->
<signer android:signature="30820243badc1df9d"/>
<!-- android-se-access signature-->
<signer
android:signature="3082044cbd852e">
<package android:name="org.nic.nfc.seaccess"/>
</signer>
</resources>
Here is a view of the project workspace
I just saw something in the logs, which I wanted to add to this thread. Seems like the is a "-1", and "-2" next to the package name. Is that supposed to be there, or is that the cause of my issue?
Here are the log messages I am talking about:
03-27 22:55:10.884: E/AndroidRuntime(9436): Caused by: java.lang.ClassNotFoundException: Didn't find class "org.nick.nfc.seaccess.MainActivity" on path: DexPathList[[zip file "/system/framework /com.android.nfc_extras.jar", zip file "/data/app/org.nick.nfc.seaccess- 1.apk"],nativeLibraryDirectories=[/data/app-lib/org.nick.nfc.seaccess-1, /vendor/lib, /system/lib]]
03-27 22:58:02.104: E/AndroidRuntime(9880): Caused by: java.lang.ClassNotFoundException: Didn't find class "org.nick.nfc.seaccess.MainActivity" on path: DexPathList[[zip file "/system/framework /com.android.nfc_extras.jar", zip file "/data/app/org.nick.nfc.seaccess- 2.apk"],nativeLibraryDirectories=[/data/app-lib/org.nick.nfc.seaccess-2, /vendor/lib, /system/lib]]
From the trace: java.lang.ClassNotFoundException: Didn't find class "org.nick.nfc.seaccess.MainActivity"
This means the class org.nick.nfc.seaccess.MainActivity is undefined or can't be loaded.
Do you have a class org.nick.nfc.seaccess.MainActivity? What is the code? Does it have a default constructor? Is it declared in the manifest?

Categories