Java.lang.RuntimeException: Cannot start ComponentInfo activity

I am working on an application in which I have to create a Lunar Calendar I am creating a custom Lunar calendar. The lunar calendar has a very limited code. But somehow I manage to create it. This is my code.

 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); webView = (WebView)this.findViewById(R.id.wv); webView.loadUrl(contentUri); // webView.loadUrl("file://D:/Andro_WS_2/LunarCalendar/assets/calendar.html"); mGestureDetector = new GestureDetector(this); webView.setOnTouchListener(this); try { Thread.sleep(1500); } catch (InterruptedException e) { e.printStackTrace(); } webView.loadUrl("javascript:pushBtm('MU')"); webView.loadUrl("javascript:pushBtm('MD')"); if(!ConfigCenter.getValue(this, Constant.KEY_WIDGET_ADDED, false)){ Toast.makeText(MainActivity.this, "Please Wait", Toast.LENGTH_LONG).show(); } } 

and when I run this code, it will work. My logcat error shows:

 03-20 04:51:41.197: E/AndroidRuntime(967): FATAL EXCEPTION: main 03-20 04:51:41.197: E/AndroidRuntime(967): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.lunarcalendar/com.example.lunarcalendar.MainActivity}: android.view.InflateException: Binary XML file line #23: Error inflating class net.youmi.android.AdView 03-20 04:51:41.197: E/AndroidRuntime(967): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) 03-20 04:51:41.197: E/AndroidRuntime(967): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 03-20 04:51:41.197: E/AndroidRuntime(967): at android.app.ActivityThread.access$600(ActivityThread.java:141) 03-20 04:51:41.197: E/AndroidRuntime(967): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 03-20 04:51:41.197: E/AndroidRuntime(967): at android.os.Handler.dispatchMessage(Handler.java:99) 03-20 04:51:41.197: E/AndroidRuntime(967): at android.os.Looper.loop(Looper.java:137) 03-20 04:51:41.197: E/AndroidRuntime(967): at android.app.ActivityThread.main(ActivityThread.java:5039) 03-20 04:51:41.197: E/AndroidRuntime(967): at java.lang.reflect.Method.invokeNative(Native Method) 03-20 04:51:41.197: E/AndroidRuntime(967): at java.lang.reflect.Method.invoke(Method.java:511) 03-20 04:51:41.197: E/AndroidRuntime(967): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 03-20 04:51:41.197: E/AndroidRuntime(967): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 03-20 04:51:41.197: E/AndroidRuntime(967): at dalvik.system.NativeStart.main(Native Method) 03-20 04:51:41.197: E/AndroidRuntime(967): Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class net.youmi.android.AdView 03-20 04:51:41.197: E/AndroidRuntime(967): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698) 03-20 04:51:41.197: E/AndroidRuntime(967): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 03-20 04:51:41.197: E/AndroidRuntime(967): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 03-20 04:51:41.197: E/AndroidRuntime(967): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 03-20 04:51:41.197: E/AndroidRuntime(967): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 03-20 04:51:41.197: E/AndroidRuntime(967): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270) 03-20 04:51:41.197: E/AndroidRuntime(967): at android.app.Activity.setContentView(Activity.java:1881) 03-20 04:51:41.197: E/AndroidRuntime(967): at com.example.lunarcalendar.MainActivity.onCreate(MainActivity.java:44) 03-20 04:51:41.197: E/AndroidRuntime(967): at android.app.Activity.performCreate(Activity.java:5104) 03-20 04:51:41.197: E/AndroidRuntime(967): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 03-20 04:51:41.197: E/AndroidRuntime(967): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) 03-20 04:51:41.197: E/AndroidRuntime(967): ... 11 more 03-20 04:51:41.197: E/AndroidRuntime(967): Caused by: java.lang.ClassNotFoundException: Didn't find class "net.youmi.android.AdView" on path: /data/app/com.example.lunarcalendar-2.apk 03-20 04:51:41.197: E/AndroidRuntime(967): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65) 03-20 04:51:41.197: E/AndroidRuntime(967): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 03-20 04:51:41.197: E/AndroidRuntime(967): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 03-20 04:51:41.197: E/AndroidRuntime(967): at android.view.LayoutInflater.createView(LayoutInflater.java:552) 03-20 04:51:41.197: E/AndroidRuntime(967): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 03-20 04:51:41.197: E/AndroidRuntime(967): ... 21 more 

and my xml

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:umadsdk="http://schemas.android.com/apk/res/com.china.calendar" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/white" android:orientation="vertical" > <WebView android:id="@+id/wv" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <net.youmi.android.AdView android:id="@+id/ad" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" /> </RelativeLayout> 
+7
source share
1 answer

I think you should change the adview class in your layout file.

In addition to defining the ad as net.youmi.android.AdView try defining it as com.google.ads.AdView in your layout.

Add your AdView as shown below:

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" <!-- Change this line also --> android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/white" android:orientation="vertical" > <WebView android:id="@+id/wv" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <com.google.ads.AdView android:id="@+id/ad" android:layout_width="fill_parent" android:layout_height="wrap_content" ads:adSize="BANNER" ads:adUnitId="your add id" /> </RelativeLayout> 
+1
source

All Articles