errors after importing v7 app compact - android

while executing the code
package com.example.swvt1;
import java.util.ArrayList;
import java.util.List;
import com.example.adapters.MyFragmentPagerAdapter;
import com.example.fragments.fragment1;
import com.example.fragments.fragment2;
import com.example.fragments.fragment3;
import com.example.fragments.fragment4;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
ViewPager viewPager;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
viewPager = (ViewPager) findViewById(R.id.view_pager);
List<Fragment> listfragments = new ArrayList<Fragment>();
listfragments.add(new fragment1());
listfragments.add(new fragment2());
listfragments.add(new fragment3());
listfragments.add(new fragment4());
MyFragmentPagerAdapter myFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), listfragments);
viewPager.setAdapter(myFragmentPagerAdapter);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
while executing the above code i am getting the errors such as no class definition found and class not found exception and the stack trace is as follows
E/AndroidRuntime(27466): FATAL EXCEPTION: main
E/AndroidRuntime(27466): Process: com.example.swvt1, PID: 27466
E/AndroidRuntime(27466): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.swvt1/com.example.swvt1.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.swvt1.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.swvt1-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
E/AndroidRuntime(27466):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2290)
E/AndroidRuntime(27466): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)
E/AndroidRuntime(27466): at android.app.ActivityThread.access$800(ActivityThread.java:156)
E/AndroidRuntime(27466): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
E/AndroidRuntime(27466): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(27466): at android.os.Looper.loop(Looper.java:211)
E/AndroidRuntime(27466): at android.app.ActivityThread.main(ActivityThread.java:5371)
E/AndroidRuntime(27466): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(27466): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(27466): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:945)
E/AndroidRuntime(27466): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:740)
E/AndroidRuntime(27466): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.swvt1.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.swvt1-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
E/AndroidRuntime(27466): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(27466): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime(27466): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/AndroidRuntime(27466): at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
E/AndroidRuntime(27466): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2280)
E/AndroidRuntime(27466): ... 10 more
E/AndroidRuntime(27466): Suppressed: java.lang.NoClassDefFoundError: com.example.swvt1.MainActivity
E/AndroidRuntime(27466): at dalvik.system.DexFile.defineClassNative(Native Method)
E/AndroidRuntime(27466): at dalvik.system.DexFile.defineClass(DexFile.java:226)
E/AndroidRuntime(27466): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
E/AndroidRuntime(27466): at dalvik.system.DexPathList.findClass(DexPathList.java:321)
E/AndroidRuntime(27466): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
E/AndroidRuntime(27466): ... 14 more
E/AndroidRuntime(27466): Suppressed: java.lang.ClassNotFoundException: com.example.swvt1.MainActivity
E/AndroidRuntime(27466): at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(27466): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime(27466): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime(27466): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime(27466): ... 13 more
E/AndroidRuntime(27466): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
What is the error I have done and Thanks in advance

Go the "Java Build Path" -> Order and export -> check all checkboxes -> clean -> build -> run
And Make Sure that You have v7 in your Library

Related

how to resolve app has stopped in android studio simulator (fragment pager adapter)

I am a beginner in android development and I have encountered some difficulty in running my app in the simulator. I am following chapter 12 of the head first textbook to design an app with tab navigation. It has four fragments and I am using the fragment pager adapter to navigate through the app. When I run the app in the simulator it is crashed with the error message "app has stopped working". My code for the main activity is as follows:
package com.hfad.bitsandpizzas;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import androidx.appcompat.widget.ShareActionProvider;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.MenuItemCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
public class MainActivity extends AppCompatActivity {
private ShareActionProvider shareActionProvider;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
SectionsPagerAdapter pagerAdapter =
new SectionsPagerAdapter(getSupportFragmentManager());
ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(pagerAdapter);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
MenuItem menuItem = menu.findItem(R.id.action_share);
shareActionProvider =
(ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
setShareActionIntent("Want to join me for pizza?");
return super.onCreateOptionsMenu(menu);
}
private void setShareActionIntent(String text) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, text);
shareActionProvider.setShareIntent(intent);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_create_order:
Intent intent = new Intent(this, OrderActivity.class);
startActivity(intent);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
#Override
public int getCount() {
return 4;
}
#Override
public Fragment getItem(int position) {
switch (position) {
case 0:
return new TopFragment();
case 1:
return new PizzaFragment();
case 2:
return new PastaFragment();
case 3:
return new StoresFragment();
}
return null;
}
}
}
the error message from the logcat is this
2020-06-04 15:10:08.263 11458-11458/com.hfad.bitsandpizzas E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.hfad.bitsandpizzas, PID: 11458
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hfad.bitsandpizzas/com.hfad.bitsandpizzas.MainActivity}: android.view.InflateException: Binary XML file line #14: Binary XML file line #14: Error inflating class android.support.v4.view.ViewPager
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: android.view.InflateException: Binary XML file line #14: Binary XML file line #14: Error inflating class android.support.v4.view.ViewPager
Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class android.support.v4.view.ViewPager
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.view.ViewPager" on path: DexPathList[[zip file "/data/app/com.hfad.bitsandpizzas-1/base.apk"],nativeLibraryDirectories=[/data/app/com.hfad.bitsandpizzas-1/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:609)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.hfad.bitsandpizzas.MainActivity.onCreate(MainActivity.java:25)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
You are useing the Androidx support Library ,but in your xml layout ,you are useing the android.support.v4.view.ViewPager , you must change the ViewPager to Androidx support Library,use: androidx.viewpager.widget.ViewPager instead.

java.lang.ClassNotFoundException in android 4.0 After Adding the Ad Mob in App

After Adding the Ad Mob in App , its working in higher version above 5.0 but its not working in 4.0 , i am getting the following exception
java.lang.RuntimeException: Unable to instantiate service g2eandroid.srs.service.MyFirebaseInstanceIDService: java.lang.ClassNotFoundException: Didn't find class "g2eandroid.srs.service.MyFirebaseInstanceIDService" on path: DexPathList[[zip file "/data/app/g2eandroid.srs-2.apk"],nativeLibraryDirectories=[/data/app-lib/g2eandroid.srs-2, /vendor/lib, /system/lib]]
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2570)
at android.app.ActivityThread.access$1800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "g2eandroid.srs.service.MyFirebaseInstanceIDService" on path: DexPathList[[zip file "/data/app/g2eandroid.srs-2.apk"],nativeLibraryDirectories=[/data/app-lib/g2eandroid.srs-2, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2567)
at android.app.ActivityThread.access$1800(ActivityThread.java:139) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5086) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
at dalvik.system.NativeStart.main(Native Method) 
Please create a class
import android.content.Context;
import android.support.multidex.MultiDexApplication;
public class EnableMultiDex extends MultiDexApplication {
private static EnableMultiDex enableMultiDex;
public static Context context;
public EnableMultiDex(){
enableMultiDex=this;
}
public static EnableMultiDex getEnableMultiDexApp() {
return enableMultiDex;
}
#Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
}
}
and in your manifest give android:name="packagename.EnableMultiDex"
eg:
<application
android:name="YourPakageName.EnableMultiDex"
android:hardwareAccelerated="true"
android:icon="#drawable/wowio_launch_logo"
android:label="#string/app_name"
android:largeHeap="true"
tools:node="replace">
Let me know whether it solved your issue.

class not found and null object reference exception out of nowhere

I have now completed all the scripting and designing with no compile time error but out of no where this run time error comes in and my app flashes away and do not get launched.
I have got all the files that it requires and everything done,
Please suggest now,
This is my MainActivity.java code thats probably throwing these exceptions
package com.example.dell.demologin;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.HashMap;
import activity.LoginActivity;
import helper.SQLiteHandler;
import helper.SessionManager;
public class MainActivity extends Activity {
private TextView txtName;
private TextView txtEmail;
private Button btnLogout;
private SQLiteHandler db;
private SessionManager session;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
txtName = (TextView) findViewById(R.id.name);
txtEmail = (TextView) findViewById(R.id.email);
btnLogout = (Button) findViewById(R.id.btnLogout);
// SqLite database handler
db = new SQLiteHandler(getApplicationContext());
// session manager
session = new SessionManager(getApplicationContext());
if (!session.isLoggedIn()) {
logoutUser();
}
// Fetching user details from sqlite
HashMap<String, String> user = db.getUserDetails();
String name = user.get("name");
String email = user.get("email");
// Displaying the user details on the screen
txtName.setText(name);
txtEmail.setText(email);
// Logout button click event
btnLogout.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
logoutUser();
}
});
}
/**
* Logging out the user. Will set isLoggedIn flag to false in shared
* preferences Clears the user data from sqlite users table
* */
private void logoutUser() {
session.setLogin(false);
db.deleteUsers();
// Launching the login activity
Intent intent = new Intent(MainActivity.this, LoginActivity.class);
startActivity(intent);
finish();
}
}
This is my logcat,
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.dell.demologin, PID: 15578
java.lang.RuntimeException: Unable to instantiate application com.android.tools.fd.runtime.BootstrapApplication: java.lang.IllegalStateException: java.lang.ClassNotFoundException: com.example.dell.demologin.AppController
at android.app.LoadedApk.makeApplication(LoadedApk.java:601)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4757)
at android.app.ActivityThread.access$1600(ActivityThread.java:159)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1445)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:152)
at android.app.ActivityThread.main(ActivityThread.java:5507)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalStateException: java.lang.ClassNotFoundException: com.example.dell.demologin.AppController
at com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:220)
at com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:239)
at android.app.Application.attach(Application.java:187)
at android.app.Instrumentation.newApplication(Instrumentation.java:1001)
at android.app.Instrumentation.newApplication(Instrumentation.java:985)
at android.app.LoadedApk.makeApplication(LoadedApk.java:586)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4757) 
at android.app.ActivityThread.access$1600(ActivityThread.java:159) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1445) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:152) 
at android.app.ActivityThread.main(ActivityThread.java:5507) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Caused by: java.lang.ClassNotFoundException: com.example.dell.demologin.AppController
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:324)
at java.lang.Class.forName(Class.java:285)
at com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:209)
at com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:239) 
at android.app.Application.attach(Application.java:187) 
at android.app.Instrumentation.newApplication(Instrumentation.java:1001) 
at android.app.Instrumentation.newApplication(Instrumentation.java:985) 
at android.app.LoadedApk.makeApplication(LoadedApk.java:586) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4757) 
at android.app.ActivityThread.access$1600(ActivityThread.java:159) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1445) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:152) 
at android.app.ActivityThread.main(ActivityThread.java:5507) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.dell.demologin.AppController" on path: DexPathList[[zip file "/data/app/com.example.dell.demologin-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.dell.demologin-2/lib/arm64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:324) 
at java.lang.Class.forName(Class.java:285) 
at com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:209) 
at com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:239) 
at android.app.Application.attach(Application.java:187) 
at android.app.Instrumentation.newApplication(Instrumentation.java:1001) 
at android.app.Instrumentation.newApplication(Instrumentation.java:985) 
at android.app.LoadedApk.makeApplication(LoadedApk.java:586) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4757) 
at android.app.ActivityThread.access$1600(ActivityThread.java:159) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1445) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:152) 
at android.app.ActivityThread.main(ActivityThread.java:5507) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Suppressed: java.lang.ClassNotFoundException: Didn't find class "com.example.dell.demologin.AppController" on path: DexPathList[[dex file "/data/data/com.example.dell.demologin/files/instant-run/dex/slice-support-annotations-23.4.0_2f85958e3577c0887206665b958d529f2917b10d-classes.dex", dex file "/data/data/com.example.dell.demologin/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.example.dell.demologin/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.example.dell.demologin/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.example.dell.demologin/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.example.dell.demologin/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.example.dell.demologin/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.example.dell.demologin/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.example.dell.demologin/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.example.dell.demologin/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.example.dell.demologin/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.example.dell.demologin/files/instant-run/dex/slice-mysql-connector-java_910883ba1d0637ad761451367a22e76261a44141-classes.dex", dex file "/data/data/com.example.dell.demologin/files/instant-run/dex/slice-jtds_dd6bef0a517729fc55f6897f784dfc3379233a03-classes.dex", dex file "/data/data/com.example.dell.demologin/files/instant-run/dex/slice-internal_impl-23.4.0_acbefc0422230ccc1164ab
E/AndroidRuntime: Error reporting crash
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.app.Application.getApplicationContext()' on a null object reference
at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:96)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
I/Process: Sending signal. PID: 15578 SIG: 9
Application terminated.
Known bug in the Google Play store upgrade process, https://code.google.com/p/android/issues/detail?id=56296

android.view.InflateException: Binary XML file line #2: Error inflating class andorid.support.v7.widget.Toolbar

Hi I trying material design thing but I got the above error. Here is my log cat:
Process: course.examples.healthcare_application, PID: 19653
java.lang.RuntimeException: Unable to start activity ComponentInfo{course.examples.healthcare_application/course.examples.healthcare_application.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class andorid.support.v7.widget.Toolbar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2702)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
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:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class andorid.support.v7.widget.Toolbar
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:904)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
at course.examples.healthcare_application.MainActivity.onCreate(MainActivity.java:15)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)
            at android.app.ActivityThread.access$900(ActivityThread.java:177)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:145)
            at android.app.ActivityThread.main(ActivityThread.java:5951)
            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:1400)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Caused by: java.lang.ClassNotFoundException: Didn't find class "andorid.support.v7.widget.Toolbar" on path: DexPathList[[zip file "/data/app/course.examples.healthcare_application-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.view.LayoutInflater.createView(LayoutInflater.java:578)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
            at android.view.LayoutInflater.parseInclude(LayoutInflater.java:904)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
            at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
            at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
            at course.examples.healthcare_application.MainActivity.onCreate(MainActivity.java:15)
            at android.app.Activity.performCreate(Activity.java:6289)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)
            at android.app.ActivityThread.access$900(ActivityThread.java:177)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:145)
            at android.app.ActivityThread.main(ActivityThread.java:5951)
            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:1400)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Suppressed: java.lang.ClassNotFoundException: andorid.support.v7.widget.Toolbar
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 24 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
app_bar.xml
<?xml version="1.0" encoding="utf-8"?>
<andorid.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#DDD">
</andorid.support.v7.widget.Toolbar>
acitivity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="course.examples.healthcare_application.MainActivity">
<include
android:id="#+id/app_bar"
layout="#layout/app_bar" />
<TextView
android:layout_below="#+id/app_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
</RelativeLayout>
MainActivity
package course.examples.healthcare_application;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends AppCompatActivity {
private Toolbar toolbar;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar= (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(toolbar);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Please help. I had looked at other posts but it doesn't solve my problem. And I am new to material design. Don't quite understand the error.
andorid.support.v7.widget.Toolbar
to
android.support.v7.widget.Toolbar
<?xml version="1.0" encoding="utf-8"?>
<andorid.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#DDD">
</andorid.support.v7.widget.Toolbar>
Misspelled android

Runtime Error while using AppCompatActivity instead of Actionbar

I am using the AppCompatActivity library to make support all the devices. After upadting the android-support-v7-appcompat library i am facing issue. But i am facing an error during run-time. I am using eclipse studio to code for android project. Any help will be appreciated.
Below is my error ,and i am getting no idea where i am going wrong.
** ERROR **
E/AndroidRuntime(6899): FATAL EXCEPTION: main
E/AndroidRuntime(6899): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.drawer.sample/com.drawer.sample.MainActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class android.support.v7.internal.widget.NativeActionModeAwareLayout
E/AndroidRuntime(6899): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
E/AndroidRuntime(6899): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
E/AndroidRuntime(6899): at android.app.ActivityThread.access$800(ActivityThread.java:144)
E/AndroidRuntime(6899): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
E/AndroidRuntime(6899): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(6899): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(6899): at android.app.ActivityThread.main(ActivityThread.java:5221)
E/AndroidRuntime(6899): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(6899): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(6899): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
E/AndroidRuntime(6899): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
E/AndroidRuntime(6899): Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class android.support.v7.internal.widget.NativeActionModeAwareLayout
E/AndroidRuntime(6899): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
E/AndroidRuntime(6899): at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
E/AndroidRuntime(6899): at android.view.LayoutInflater.parseInclude(LayoutInflater.java:890)
E/AndroidRuntime(6899): at android.view.LayoutInflater.rInflate(LayoutInflater.java:802)
E/AndroidRuntime(6899): at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
E/AndroidRuntime(6899): at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
E/AndroidRuntime(6899): at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
E/AndroidRuntime(6899): at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:299)
E/AndroidRuntime(6899): at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
E/AndroidRuntime(6899): at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
E/AndroidRuntime(6899): at com.drawer.sample.MainActivity.onCreate(MainActivity.java:12)
E/AndroidRuntime(6899): at android.app.Activity.performCreate(Activity.java:5933)
E/AndroidRuntime(6899): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
E/AndroidRuntime(6899): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
E/AndroidRuntime(6899): ... 10 more
E/AndroidRuntime(6899): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.internal.widget.NativeActionModeAwareLayout" on path: DexPathList[[zip file "/data/app/com.drawer.sample-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
E/AndroidRuntime(6899): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(6899): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime(6899): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/AndroidRuntime(6899): at android.view.LayoutInflater.createView(LayoutInflater.java:571)
E/AndroidRuntime(6899): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
E/AndroidRuntime(6899): ... 23 more
E/AndroidRuntime(6899): Suppressed: java.lang.ClassNotFoundException: android.support.v7.internal.widget.NativeActionModeAwareLayout
E/AndroidRuntime(6899): at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(6899): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime(6899): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime(6899): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime(6899): ... 26 more
E/AndroidRuntime(6899): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar_layout"/>
<TextView
android:text="#string/app_name"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textColor="#000000"
android:layout_marginTop="110dp"/>
</LinearLayout>
MainActivty.java
package com.drawer.sample;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.support.v7.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
}
}
Style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="AppTheme.Base">
</style>
<style name="AppTheme.Base" parent = "Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primaryDark</item>
<item name="colorAccent">#color/accent</item>
</style>
ActionBar is used as Toolbar in material design. So add theme with no action bar and use
following to use Toolbar in xml.
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:iosched="http://schemas.android.com/apk/res-auto"
style="#style/HeaderBar"
iosched:theme="#style/ActionBarThemeOverlay"
iosched:popupTheme="#style/ActionBarPopupThemeOverlay"
android:id="#+id/toolbar_actionbar"
iosched:titleTextAppearance="#style/ActionBar.TitleText"
iosched:contentInsetStart="?actionBarInsetStart"
android:layout_width="match_parent"
android:layout_height="?actionBarSize" />
I found the solution of may error, i have to add the implements override methods of appCompatActivity. Below is the code by which i have fix it.
package com.drawer.sample;
import android.os.Bundle;
import android.support.v7.view.ActionMode;
import android.support.v7.widget.Toolbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.AppCompatCallback;
public class MainActivity extends AppCompatActivity implements AppCompatCallback {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
}
#Override
public void onSupportActionModeFinished(ActionMode mode) {
// TODO Auto-generated method stub
super.onSupportActionModeFinished(mode);
}
#Override
public void onSupportActionModeStarted(ActionMode mode) {
// TODO Auto-generated method stub
super.onSupportActionModeStarted(mode);
}
}
And i can add the statusbar as well actionbar. :)
Have you ever try to add this code sample in your gradle file?
android {
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude group: 'com.android.support', module: 'support-annotations'
} }

Categories

Resources