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'
} }
Related
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
Hi every one I have created a fragment class and included in my project.Now the problem is the classes which i have included fragment is not working and it get stops unfortunately.It shows error like this.
09-12 10:26:31.066 7892-7892/com.sentientit.theiWedplanner E/AndroidRuntime? FATAL EXCEPTION: main
Process: com.sentientit.theiWedplanner, PID: 7892
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sentientit.theiWedplanner/com.sentientit.theiWedplanner.Frontpage}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2359)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2411)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5323)
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:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:341)
at android.app.Activity.setContentView(Activity.java:1948)
at com.sentientit.theiWedplanner.Frontpage.onCreate(Frontpage.java:41)
at android.app.Activity.performCreate(Activity.java:5343)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2323)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2411)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5323)
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:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.sentientit.theiWedplanner.Fragadmob: make sure class name exists, is public, and has an empty constructor that is public
at android.app.Fragment.instantiate(Fragment.java:597)
at android.app.Fragment.instantiate(Fragment.java:561)
at android.app.Activity.onCreateView(Activity.java:4841)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:341)
at android.app.Activity.setContentView(Activity.java:1948)
at com.sentientit.theiWedplanner.Frontpage.onCreate(Frontpage.java:41)
at android.app.Activity.performCreate(Activity.java:5343)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2323)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2411)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5323)
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:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sentientit.theiWedplanner.Fragadmob" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.sentientit.theiWedplanner-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.sentientit.theiWedplanner-1, /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.Fragment.instantiate(Fragment.java:583)
at android.app.Fragment.instantiate(Fragment.java:561)
at android.app.Activity.onCreateView(Activity.java:4841)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:341)
at android.app.Activity.setContentView(Activity.java:1948)
at com.sentientit.theiWedplanner.Frontpage.onCreate(Frontpage.java:41)
at android.app.Activity.performCreate(Activity.java:5343)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2323)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2411)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5323)
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:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
at dalvik.system.NativeStart.main(Native Method)
fragment xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adview153613"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/aagr_background2" >
<ImageView
android:id="#+id/addviewimage"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:src="#drawable/adview1536132" />
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="-------------"
/>
<ImageView
android:id="#+id/addviewimage1"
android:layout_width="#dimen/fwh"
android:layout_height="#dimen/fwh"
android:layout_alignParentRight="true"
android:layout_marginRight="23dp"
android:src="#drawable/close" />
</RelativeLayout>
fragment java file
package com.sentientit.theiWedplanner;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
public class Fragadmob extends Fragment {
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragadmob, container, false);
//Admob
RelativeLayout gonad=(RelativeLayout)rootView.findViewById(R.id.adview153613);
ImageView addviewimage=(ImageView)rootView.findViewById(R.id.addviewimage);
ImageView inap=(ImageView)rootView.findViewById(R.id.addviewimage1);
// AdView adView = new AdView(getActivity());
AdView adView = (AdView)rootView.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.build();
adView.loadAd(adRequest);
addviewimage.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent viewIntent =
new Intent("android.intent.action.VIEW",
Uri.parse("https://play.google.com/store/apps/developer?id=SentientIT+America,+LLC"));
startActivity(viewIntent);
}
});
inap.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(getActivity(),Inapp.class);
startActivity(intent);
}
});
if(addviewimage.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
{
addviewimage.getLayoutParams().height = 30;
// code to do for Portrait Mode
}
return rootView;
}
}
gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.sentientit.theiWedplanner"
minSdkVersion 9
targetSdkVersion 21
versionCode 13
versionName "11.0"
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.2.0'
compile 'joda-time:joda-time:2.4'
compile files('libs/bugsense-3.6.1.jar')
compile files('libs/core.jar')
compile files('libs/MtUtils.jar')
compile files('libs/socialauth-android-3.2.jar')
compile files('libs/universal-image-loader-1.6.1-with-src.jar')
compile files('libs/zxingjar-1.1.jar')
compile 'com.google.android.gms:play-services:7.5.0'
compile files('libs/ksoap2.jar')
compile 'com.android.support:multidex:1.0.1'
compile files('libs/twitter4j.jar')
}
Please give me the possible solution to solve it friends
Thank you in advance
error during validation of xml
Error:(8, 55) cvc-elt.1: Cannot find the declaration of element 'RelativeLayout'.
Error:(1, 56) s4s-elt-schema-ns: The namespace of element 'x' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'.
Error:(1, 56) s4s-elt-invalid: Element 'x' is not a valid element in a schema document.
Error:(1, 56) schema_reference.4: Failed to read schema document 'null', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
class loads fragment file
package com.sentientit.theiWedplanner;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;
import com.bugsense.trace.BugSenseHandler;
import com.google.android.gms.ads.AdView;
public class Frontpage extends FragmentActivity {
/** Called when the activity is first created. */
SharedPreferences sharedPreferences;
#Override
public void onStart() {
super.onStart();
// The rest of your onStart() code.
// // EasyTracker.getInstance(this).activityStart(this); // Add this method.
}
#Override
public void onStop() {
super.onStop();
// The rest of your onStop() code.
// EasyTracker.getInstance(this).activityStop(this); // Add this method.
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); BugSenseHandler.initAndStartSession(this, "68640bea");
//requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.front);
// getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.main1);
//TextView ctitle=(TextView)findViewById(R.id.customtitlebar);
//ctitle.setText("Resources");
AdView adview=(AdView)findViewById(R.id.ad);
if(GlobalClass.adm){
adview.setVisibility(View.GONE);
}
RelativeLayout clic =(RelativeLayout)findViewById(R.id.fron);
clic.setOnClickListener(new OnClickListener() {
//#Override
#Override
public void onClick(View v)
{
// TODO Auto-generated method stub
Intent intent=new Intent(Frontpage.this,welcomeuser1.class);
//Intent intent=new Intent(Frontpage.this,ZXingJarDemoActivity.class);
startActivity(intent);
finish();
}
});
}
}
Watch out for this log message
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
You are having some problem with the xml view file . and most probably in line no 11 . you can try removing
xmlns:ads="http://schemas.android.com/apk/res-auto"
from adview.The namespace is declared in the root element .Also the fill_parent is depreciated . use match_parent
I have an activity which has 2 buttons. The fragment in my activity would change on button click. But I am facing issue as -- android.view.InflateException: Binary XML file line #24: Error inflating class fragment .
Below is my code-
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"
tools:context=".MainActivity">
<Button
android:id="#+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="selectFrag"
android:text="Select Fragment 1" />
<Button
android:id="#+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="selectFrag"
android:text="Select Fragment 2" />
<fragment
android:id="#+id/fragment_place"
android:name="com.example.rahul.fragmentdemo.FragmentOne"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="#layout/fragment_one" />
</LinearLayout>
MainActivity.java
package com.example.rahul.fragmentdemo;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void selectFrag(View view) {
Fragment fr = null;
if (view == findViewById(R.id.button2)) {
fr = new FragmentTwo();
} else {
fr = new FragmentOne();
}
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fm.beginTransaction();
fragmentTransaction.replace(R.id.fragment_place, fr);
fragmentTransaction.commit();
}
}
FragmentOne.java
package com.example.rahul.fragmentdemo;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class FragmentOne extends Fragment {
public FragmentOne() {
// Required empty public constructor
}
#Override
public void onCreate(Bundle savedInstanceState) {
Log.i("Fragment Demo", "Fragment_One onCreate()");
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_one, container, false);
return view;
}
}
fragment_one.xml
<FrameLayout 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" tools:context="com.example.rahul.fragmentdemo.FragmentOne">
<!-- TODO: Update blank fragment layout -->
<TextView
android:id="#+id/tvFragment_1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="This is Fragment 1" />
</FrameLayout>
similar to FragmentOne.java and fragment_two.xml, my code has FragmentTwo.java and fragment_two.xml respectively.
I get exception as--
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.rahul.fragmentdemo/com.example.rahul.fragmentdemo.MainActivity}: android.view.InflateException: Binary XML file line #24: Error inflating class fragment
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.view.InflateException: Binary XML file line #24: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
at android.app.Activity.setContentView(Activity.java:2144)
at com.example.rahul.fragmentdemo.MainActivity.onCreate(MainActivity.java:18)
at android.app.Activity.performCreate(Activity.java:5937)
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)
Caused by: android.support.v4.app.SuperNotCalledException: Fragment FragmentOne{3fdec5ae #0 id=0x7f0c0051} did not call through to super.onCreate()
at android.support.v4.app.Fragment.performCreate(Fragment.java:1768)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:917)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1116)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1218)
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2170)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:300)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
at android.app.Activity.setContentView(Activity.java:2144)
at com.example.rahul.fragmentdemo.MainActivity.onCreate(MainActivity.java:18)
at android.app.Activity.performCreate(Activity.java:5937)
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)
-- where MainActivity.java:18 refers to
setContentView(R.layout.activity_main);
As the error log says, there is missing super.onCreate in FragmentOne.java:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i("Fragment Demo", "Fragment_One onCreate()");
}
So my code simply makes a list of CardViews using RecyclerView. Upon running my code i kept getting a weird error claiming there was an error in my xml. After tinkering for a while i found out that in my layout file if i change <RecyclerView> to <android.support.v7.widget.RecyclerView> everything would work just fine. Why is this happening? My activity.
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Menu;
import android.view.MenuItem;
import java.util.ArrayList;
public class CardListActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_card_list);
RecyclerView recyclerView = (RecyclerView)findViewById(R.id.cardList);
recyclerView.setHasFixedSize(true);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(linearLayoutManager);
ArrayList<String> list = new ArrayList<>();
for(int i = 0; i < 20; i++) {list.add("Item " + i);}
CardListAdapter cardListAdapter = new CardListAdapter(list);
recyclerView.setAdapter(cardListAdapter);
}
}
My Adapter
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.List;
public class CardListAdapter extends RecyclerView.Adapter<CardListAdapter.CardListViewHolder> {
private List<String> list;
public CardListAdapter(List<String> list) {
this.list = list;
}
#Override
public CardListViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.card_layout,viewGroup,false);
return new CardListViewHolder(v);
}
#Override
public void onBindViewHolder(CardListViewHolder cardListViewHolder, int i) {
String s = list.get(i);
cardListViewHolder.title.setText(s);
}
#Override
public int getItemCount() {
return list.size();
}
public static class CardListViewHolder extends RecyclerView.ViewHolder {
TextView title;
public CardListViewHolder(View itemView) {
super(itemView);
title = (TextView)itemView.findViewById(R.id.title);
}
}
}
My layout file, note, changing <RecyclerView> to <android.support.v7.widget.RecyclerView> fixes the error.
<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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin" tools:context=".CardListActivity">
<RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/cardList">
</RecyclerView>
When i run with <RecyclerView> i get this error, .
`Process: com.liquidink.lollipopmaterialui, PID: 7317
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.liquidink.lollipopmaterialui/com.liquidink.lollipopmaterialui.CardListActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class RecyclerView
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.view.InflateException: Binary XML file line #8: Error inflating class RecyclerView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
at com.liquidink.lollipopmaterialui.CardListActivity.onCreate(CardListActivity.java:18)
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)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.RecyclerView" on path: DexPathList[[zip file "/data/app/com.liquidink.lollipopmaterialui-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:571)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:665)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:65)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
at com.liquidink.lollipopmaterialui.CardListActivity.onCreate(CardListActivity.java:18)
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)
Suppressed: java.lang.ClassNotFoundException: android.view.RecyclerView
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)
... 26 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
`
You should add the RecyclerView in the XML in this way:
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/cardList">
</android.support.v7.widget.RecyclerView>
Hope it helps!
RecyclerView is not included in base Android framework, only widgets in base Android framework (like ListView, GridView etc) can be specified in layout without full namespace. RecyclerView is part of recyclerview-v7 support library.
I meet this problem today.
And solved it.
first step:keep the support-libs you used are same version
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
second step:you should add recyclerView to your proguard files
-keep class android.support.v7.widget.** {*;}
// I`ve just keep all widgets
Make sure to include before you add RecyclerView to your XML
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.android.support:appcompat-v7:22.2.0'
If you created RecyclerView in your XML before adding these dependencies, to make it work you should remove (comment) your recycler view, build project without it and then add it back. Otherwise it still shows Inflate exception in binary XML line #n.
Check reference in build.gradle
In your layout xml file be, write your RecyclerView component's name as a whole with its package like that android.support.v7.widget.RecyclerViewnot like RecyclerView
now ready to lunch. Good trails
I have an android app that shows a map via a SupportMapFragment. The app was running fine for the past several months until just recently I upgraded my phone from 4.4.4 to 5.0 (via the official OTA update). Now the app crashes and I get the following stack trace:
11-18 12:51:49.699 12594-12594/com.foo.bar E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.foo.bar, PID: 12594
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.foo.bar/com.foo.bar.CallActivity}: android.view.InflateException: Binary XML file line #89: Error inflating class fragment
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.view.InflateException: Binary XML file line #89: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
at android.app.Activity.setContentView(Activity.java:2144)
at com.foo.bar.CallActivity.onCreate(CallActivity.java:89)
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)
Caused by: java.lang.SecurityException: Incorrect signature
at org.apache.harmony.security.utils.JarUtils.verifySignature(JarUtils.java:223)
at java.util.jar.JarVerifier.verifyCertificate(JarVerifier.java:294)
at java.util.jar.JarVerifier.readCertificates(JarVerifier.java:268)
at java.util.jar.JarFile.getInputStream(JarFile.java:380)
at libcore.net.url.JarURLConnectionImpl.getInputStream(JarURLConnectionImpl.java:222)
at java.net.URL.openStream(URL.java:470)
at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:444)
at java.lang.Class.getResourceAsStream(Class.java:1334)
at com.google.l.a.a.a.a(Unknown Source)
at com.google.l.a.a.a.a(Unknown Source)
at com.google.maps.api.android.lib6.b.e.<init>(Unknown Source)
at com.google.maps.api.android.lib6.b.e.<init>(Unknown Source)
at com.google.maps.api.android.lib6.b.e.a(Unknown Source)
at com.google.maps.api.android.lib6.c.dm.a(Unknown Source)
at com.google.maps.api.android.lib6.c.dw.a(Unknown Source)
at com.google.maps.api.android.lib6.c.v.a(Unknown Source)
at com.google.maps.api.android.lib6.c.u.a(Unknown Source)
at com.google.android.gms.maps.internal.u.onTransact(SourceFile:107)
at android.os.Binder.transact(Binder.java:380)
at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment$a.onCreateView(Unknown Source)
at com.google.android.gms.dynamic.a$4.b(Unknown Source)
at com.google.android.gms.dynamic.a.a(Unknown Source)
at com.google.android.gms.dynamic.a.onCreateView(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:920)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1206)
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2159)
at android.support.v4.app.FragmentActivity.onCreateVie
Here is my layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/myLayout"
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=".CallActivity"
android:orientation="vertical"
android:background="#FFFFFF" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</LinearLayout>
here's my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.foo.bar"
minSdkVersion 9
targetSdkVersion 21
versionCode 126
versionName "1.0.126"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-project.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:21.0.+'
compile 'com.google.android.gms:play-services:6.1.71'
compile fileTree(dir: 'libs', include: '*.jar')
}
and here is the relevant bits of the activity:
public class CallActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_call); // this is line 89 (the line referenced in the stack trace)
...
The same app still works fine on another phone with an older version of android. And if I remove the fragment from the layout, it runs without crashing on my phone with 5.0 (of course without the map), so I'm fairly certain it's the map fragment that's causing the issue.
Has anyone else seen anything like this? Any ideas of what to try?
Try to change
static {
Security.addProvider(new BouncyCastleProvider());
}
with
static {
Security.insertProviderAt(new BouncyCastleProvider(), 1);
}
See also
https://github.com/rtyley/spongycastle-old/issues/10
I figured it out. It was related to spongycastle. I had the following in my application class:
static {
Security.addProvider(new BouncyCastleProvider());
}
As soon as I commented out that block, it started working.
Remove BouncyCastle/SpongyCastle provider when Google Map view is created.
Then add it again when Google Map view is destroyed.
Create fragment inherited from SupportMapFragment.
Override onCreateView and onDestroyView.
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (Build.VERSION.RELEASE.equals("5.0"))
{
Security.removeProvider("SC");
}
return super.onCreateView(inflater, container, savedInstanceState);
}
#Override
public void onDestroyView() {
if (Build.VERSION.RELEASE.equals("5.0"))
{
Security.addProvider(new org.spongycastle.jce.provider.BouncyCastleProvider());
}
super.onDestroyView();
}
Use this inherited fragment instead of SuuportMapFragment in layout xml.