ClassNotFound when trying to implement AdMob banner - android

I am getting a very annoying ClassNotFound exception when trying to implement an admob banner in my android app, using admob sdk 4.3.1. I have used the following implementation:
Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10"
/>
....
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/bigmainlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#color/grey">
<com.google.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="xxxx"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR"
ads:loadAdOnCreate="true"/>
</LinearLayout>
Project.properties
target=android-14
Error:
03-21 22:00:25.993: E/AndroidRuntime(333): FATAL EXCEPTION: main 03-21
22:00:25.993: E/AndroidRuntime(333): java.lang.RuntimeException:
Unable to start activity
ComponentInfo{com.xxxx/com.xxxx.MainActivity}:
android.view.InflateException: Binary XML file line #125: Error
inflating class com.google.ads.AdView 03-21 22:00:25.993:
E/AndroidRuntime(333): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-21 22:00:25.993: E/AndroidRuntime(333): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-21 22:00:25.993: E/AndroidRuntime(333): at
android.app.ActivityThread.access$1500(ActivityThread.java:117) 03-21
22:00:25.993: E/AndroidRuntime(333): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-21 22:00:25.993: E/AndroidRuntime(333): at
android.os.Handler.dispatchMessage(Handler.java:99) 03-21
22:00:25.993: E/AndroidRuntime(333): at
android.os.Looper.loop(Looper.java:123) 03-21 22:00:25.993:
E/AndroidRuntime(333): at
android.app.ActivityThread.main(ActivityThread.java:3683) 03-21
22:00:25.993: E/AndroidRuntime(333): at
java.lang.reflect.Method.invokeNative(Native Method) 03-21
22:00:25.993: E/AndroidRuntime(333): at
java.lang.reflect.Method.invoke(Method.java:507) 03-21 22:00:25.993:
E/AndroidRuntime(333): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-21 22:00:25.993: E/AndroidRuntime(333): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 03-21
22:00:25.993: E/AndroidRuntime(333): at
dalvik.system.NativeStart.main(Native Method) 03-21 22:00:25.993:
E/AndroidRuntime(333): Caused by: android.view.InflateException:
Binary XML file line #125: Error inflating class com.google.ads.AdView
03-21 22:00:25.993: E/AndroidRuntime(333): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
03-21 22:00:25.993: E/AndroidRuntime(333): at
android.view.LayoutInflater.rInflate(LayoutInflater.java:623) 03-21
22:00:25.993: E/AndroidRuntime(333): at
android.view.LayoutInflater.rInflate(LayoutInflater.java:626) 03-21
22:00:25.993: E/AndroidRuntime(333): at
android.view.LayoutInflater.inflate(LayoutInflater.java:408) 03-21
22:00:25.993: E/AndroidRuntime(333): at
android.view.LayoutInflater.inflate(LayoutInflater.java:320) 03-21
22:00:25.993: E/AndroidRuntime(333): at
android.view.LayoutInflater.inflate(LayoutInflater.java:276) 03-21
22:00:25.993: E/AndroidRuntime(333): at
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
03-21 22:00:25.993: E/AndroidRuntime(333): at
android.app.Activity.setContentView(Activity.java:1657) 03-21
22:00:25.993: E/AndroidRuntime(333): at
com.xxxx.MainActivity.onCreate(FreeMedsActivity.java:55) 03-21
22:00:25.993: E/AndroidRuntime(333): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-21 22:00:25.993: E/AndroidRuntime(333): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-21 22:00:25.993: E/AndroidRuntime(333): ... 11 more 03-21
22:00:25.993: E/AndroidRuntime(333): Caused by:
java.lang.ClassNotFoundException: com.google.ads.AdView in loader
dalvik.system.PathClassLoader[/data/app/com.xxxx-2.apk] 03-21
22:00:25.993: E/AndroidRuntime(333): at
dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
03-21 22:00:25.993: E/AndroidRuntime(333): at
java.lang.ClassLoader.loadClass(ClassLoader.java:551) 03-21
22:00:25.993: E/AndroidRuntime(333): at
java.lang.ClassLoader.loadClass(ClassLoader.java:511) 03-21
22:00:25.993: E/AndroidRuntime(333): at
android.view.LayoutInflater.createView(LayoutInflater.java:471) 03-21
22:00:25.993: E/AndroidRuntime(333): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570
)
I get a similar classnotfound exception when creating the adview in code and adding it to the layout. I get this error on OS 2.2, 2.3.3, 2.3.7, and 4.0. I have added the admobsdk.jar to the build path. I have tried switching the minSSdkVersion to 14. I am using eclipse indigo.
I am wondering if this has to do with how I am adding the .jar. I have it copied into a /lib folder in the project, and then either do add to build path or preferences-->build path-->add JAR. I am wondering if somehow the app doesn't know where to find the .jar still...

Turns out r17 of Android Tools requires the /lib folder to be /libs, and the SDK has to be placed in there and referenced internally in order for it to be included in the apk.
Check out this link for more information.

I have same problem
I was fix it in Eclipse by
Project -> Clean
Project -> propertise -> Java build path -> Order and Export (Check googleAdmod jar)
Hope this help!

Related

Error when taking a screenshot in Android

I'm trying to take a screen shot of a chart I'm drawing, but everytime I try I get a NullExceptionPointer.
Here is my code :
lineChart.setChartData(array1,array2,xd);
View v1 = lineChart.getRootView();
v1.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
Where lineChart is a custom View
This logcat indicates this line as null: bitmap = Bitmap.createBitmap(v1.getDrawingCache());
here is my logcat :
04-01 19:21:11.524: E/AndroidRuntime(333): FATAL EXCEPTION: main
04-01 19:21:11.524: E/AndroidRuntime(333): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.appui/com.example.appui.CompareActivity}: java.lang.NullPointerException
04-01 19:21:11.524: E/AndroidRuntime(333): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
04-01 19:21:11.524: E/AndroidRuntime(333): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-01 19:21:11.524: E/AndroidRuntime(333): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-01 19:21:11.524: E/AndroidRuntime(333): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-01 19:21:11.524: E/AndroidRuntime(333): at android.os.Handler.dispatchMessage(Handler.java:99)
04-01 19:21:11.524: E/AndroidRuntime(333): at android.os.Looper.loop(Looper.java:123)
04-01 19:21:11.524: E/AndroidRuntime(333): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-01 19:21:11.524: E/AndroidRuntime(333): at java.lang.reflect.Method.invokeNative(Native Method)
04-01 19:21:11.524: E/AndroidRuntime(333): at java.lang.reflect.Method.invoke(Method.java:507)
04-01 19:21:11.524: E/AndroidRuntime(333): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-01 19:21:11.524: E/AndroidRuntime(333): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-01 19:21:11.524: E/AndroidRuntime(333): at dalvik.system.NativeStart.main(Native Method)
04-01 19:21:11.524: E/AndroidRuntime(333): Caused by: java.lang.NullPointerException
04-01 19:21:11.524: E/AndroidRuntime(333): at android.graphics.Bitmap.createBitmap(Bitmap.java:367)
04-01 19:21:11.524: E/AndroidRuntime(333): at com.example.appui.CompareActivity.onCreate(CompareActivity.java:37)
04-01 19:21:11.524: E/AndroidRuntime(333): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-01 19:21:11.524: E/AndroidRuntime(333): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-01 19:21:11.524: E/AndroidRuntime(333): ... 11 more
I haven't used getRootView, but the documentation states it
Returns the topmost view containing this view
If it is the topmost View by itself, it would return null. Try
View v1 = (View)lineChart;
instead.
From the documentation (and from here) , I guess you could force the Drawing Cache to be built by adding
// this is the important code :)
// Without it the view will have a dimension of 0,0 and the bitmap will be null
v1.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
v1.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());
v1.buildDrawingCache();
before you get the bitmap with
bitmap = Bitmap.createBitmap(v1.getDrawingCache());
The documentation for View.getDrawingCache(boolean) states:
Returns the bitmap in which this view drawing is cached. The returned
bitmap is null when caching is disabled.
Set the drawing cache to true using setDrawingCacheEnabled(boolean). You can also check if the drawing cache is enabled using isDrawingCacheEnabled().

Insert Google maps into my Android app

Hello i will be needing help with my Android app to insert google maps into the app, but every time i do that the app chrashes, and i'm going to insert my code below if there is somebody that can help my to find the problem with the code.
Androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.maret.maps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="17" />
<permission
android:name="com.maret.toilet.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-permission android:name="com.maret.toilet.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.maret.toilet.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="***MY_API_KEY****"/>
</application>
</manifest>
Here is my activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="My Location"
android:onClick="getLocation"
android:layout_weight="0"
/>
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment"/>
</LinearLayout>
Here is my MainActivity.java
package com.maret.maps;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
MY ERROR LOG
03-19 08:41:45.552: E/Trace(641): error opening trace file:
No such file or directory (2)
03-19 08:41:45.861: D/AndroidRuntime(641):
Shutting down VM
03-19 08:41:45.872: W/dalvikvm(641):
threadid=1: thread exiting with uncaught exception (group=0x40a13300)
03-19 08:41:45.891: E/AndroidRuntime(641): FATAL EXCEPTION: main
03-19 08:41:45.891: E/AndroidRuntime(641):
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.maret.toilet/com.maret.toilet.MainActivity}: android.view.InflateException:
Binary XML file line #15: Error inflating class fragment
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.app.ActivityThread.access$600(ActivityThread.java:130)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.os.Handler.dispatchMessage(Handler.java:99)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.os.Looper.loop(Looper.java:137)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.app.ActivityThread.main(ActivityThread.java:4745)
03-19 08:41:45.891: E/AndroidRuntime(641):
at java.lang.reflect.Method.invokeNative(Native Method)
03-19 08:41:45.891: E/AndroidRuntime(641):
at java.lang.reflect.Method.invoke(Method.java:511)
03-19 08:41:45.891: E/AndroidRuntime(641):
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
03-19 08:41:45.891: E/AndroidRuntime(641):
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-19 08:41:45.891: E/AndroidRuntime(641):
at dalvik.system.NativeStart.main(Native Method)
03-19 08:41:45.891: E/AndroidRuntime(641):
Caused by: android.view.InflateException:
Binary XML file line #15: Error inflating class fragment
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
03-19 08:41:45.891: E/AndroidRuntime(641):
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.app.Activity.setContentView(Activity.java:1867)
03-19 08:41:45.891: E/AndroidRuntime(641):
at com.maret.toilet.MainActivity.onCreate(MainActivity.java:12)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.app.Activity.performCreate(Activity.java:5008)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
03-19 08:41:45.891: E/AndroidRuntime(641): ... 11 more
03-19 08:41:45.891: E/AndroidRuntime(641):
Caused by: android.app.Fragment$InstantiationException:
Unable to instantiate fragment com.google.android.gms.maps.MapFragment:
make sure class name exists, is public, and has an empty constructor that is public
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.app.Fragment.instantiate(Fragment.java:584)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.app.Fragment.instantiate(Fragment.java:552)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.app.Activity.onCreateView(Activity.java:4656)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
03-19 08:41:45.891: E/AndroidRuntime(641): ... 21 more
03-19 08:41:45.891: E/AndroidRuntime(641):
Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment
03-19 08:41:45.891: E/AndroidRuntime(641):
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-19 08:41:45.891: E/AndroidRuntime(641):
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-19 08:41:45.891: E/AndroidRuntime(641):
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-19 08:41:45.891: E/AndroidRuntime(641):
at android.app.Fragment.instantiate(Fragment.java:574)
03-19 08:41:45.891: E/AndroidRuntime(641): ... 24 more
HERE IS THE NEW LAYOUT AND ACTIVITY
THIS IS main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
* HERE IS MY main.java **
package com.maret.maps;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class Main extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
#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;
}
}
HERE IS THE NEW LOGCAT WHEN THE APP CHRASHES**
03-21 12:23:03.633: E/Trace(958): error opening trace file: No such file or directory (2)
03-21 12:23:04.422: D/AndroidRuntime(958): Shutting down VM
03-21 12:23:04.432: W/dalvikvm(958): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
03-21 12:23:04.452: E/AndroidRuntime(958): FATAL EXCEPTION: main
03-21 12:23:04.452: E/AndroidRuntime(958): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.maret.maps/com.maret.maps.Main}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
03-21 12:23:04.452: E/AndroidRuntime(958): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
03-21 12:23:04.452: E/AndroidRuntime(958): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
03-21 12:23:04.452: E/AndroidRuntime(958): at android.app.ActivityThread.access$600(ActivityThread.java:130)
03-21 12:23:04.452: E/AndroidRuntime(958): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
03-21 12:23:04.452: E/AndroidRuntime(958): at android.os.Handler.dispatchMessage(Handler.java:99)
03-21 12:23:04.452: E/AndroidRuntime(958): at android.os.Looper.loop(Looper.java:137)
03-21 12:23:04.452: E/AndroidRuntime(958): at android.app.ActivityThread.main(ActivityThread.java:4745)
03-21 12:23:04.452: E/AndroidRuntime(958): at java.lang.reflect.Method.invokeNative(Native Method)
03-21 12:23:04.452: E/AndroidRuntime(958): at java.lang.reflect.Method.invoke(Method.java:511)
03-21 12:23:04.452: E/AndroidRuntime(958): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
03-21 12:23:04.452: E/AndroidRuntime(958): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-21 12:23:04.452: E/AndroidRuntime(958): at dalvik.system.NativeStart.main(Native Method)
03-21 12:23:04.452: E/AndroidRuntime(958): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
03-21 12:23:04.452: E/AndroidRuntime(958): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
03-21 12:23:04.452: E/AndroidRuntime(958): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
03-21 12:23:04.452: E/AndroidRuntime(958): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
03-21 12:23:04.452: E/AndroidRuntime(958): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-21 12:23:04.452: E/AndroidRuntime(958): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
03-21 12:23:04.452: E/AndroidRuntime(958): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
03-21 12:23:04.452: E/AndroidRuntime(958): at android.app.Activity.setContentView(Activity.java:1867)
03-21 12:23:04.452: E/AndroidRuntime(958): at com.maret.maps.Main.onCreate(Main.java:12)
03-21 12:23:04.452: E/AndroidRuntime(958): at android.app.Activity.performCreate(Activity.java:5008)
03-21 12:23:04.452: E/AndroidRuntime(958): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
03-21 12:23:04.452: E/AndroidRuntime(958): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
03-21 12:23:04.452: E/AndroidRuntime(958): ... 11 more
03-21 12:23:04.452: E/AndroidRuntime(958): Caused by: java.lang.ClassCastException: com.google.android.gms.maps.SupportMapFragment cannot be cast to android.app.Fragment
03-21 12:23:04.452: E/AndroidRuntime(958): at android.app.Fragment.instantiate(Fragment.java:577)
03-21 12:23:04.452: E/AndroidRuntime(958): at android.app.Fragment.instantiate(Fragment.java:552)
03-21 12:23:04.452: E/AndroidRuntime(958): at android.app.Activity.onCreateView(Activity.java:4656)
03-21 12:23:04.452: E/AndroidRuntime(958): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
03-21 12:23:04.452: E/AndroidRuntime(958): ... 21 more
03-21 12:23:07.973: I/Process(958): Sending signal. PID: 958 SIG: 9
Here is blog post I wrote on how to create a Map fragment in your application:
Google Maps API V2
From your code it look like your permission are not defined properly, you need to add this:
<permission android:name="com.maret.maps.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.maret.maps.permission.MAPS_RECEIVE"/>
And please add your logcat stack trace at crash moment so we could understand more clearly what the problem is.
UPDATE:
From the error you are receiving:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.maret.toilet/com.maret.toilet.MainActivity}: android.view.InflateException:
Binary XML file line #15: Error inflating class fragment
it's seems that you are not referencing the google-play-services library as needed, and this is the reason the fragment can't be inflated. the MapFragment class can't be find.
please check the guide that I posted at the beginning of the answer to see how to make the referencing correctly.
Your application tag in your manifest is missing this line
<uses-library android:name="com.google.android.maps" />
Add that and it should fix the crash
EDIT : This will only work for maps api version 1

following exception in android simulator 2.0

i got following strange exception on only andorid simulator 2.0
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.markupartist.android.example.pulltorefresh/com.markupartist.android.example.pulltorefresh.PullToRefreshActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class com.markupartist.android.widget.PullToRefreshListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.markupartist.android.widget.PullToRefreshListView
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
at android.app.Activity.setContentView(Activity.java:1647)
at com.markupartist.android.example.pulltorefresh.PullToRefreshActivity.onCreate(PullToRefresh Activity.java:21)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at com.markupartist.android.widget.PullToRefreshListView. (PullToRefreshListView.java:54)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
... 21 more
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030002
at android.content.res.Resources.getValue(Resources.java:892)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:1869)
at android.content.res.Resources.getLayout(Resources.java:731)
at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.markupartist.android.widget.PullToRefreshListView.init(PullToRefreshListView.java:80)
... 25 more
when i tested on andorid 1.6 , 2.01,2.1,2.2,2.3 ,4.0 it works completely,
is this a simulator bug of 2.0
please give me some information about this
Thanks

cannot load HelloWorld example in phonegap android

I am new with PhoneGap and I am using it for android. I am following step-by-step the tutorial HelloPhoneGap from http://phonegap.com/start/#android. at first run it it runs ok, but later-on when I run it i got this error:
logcat:
03-21 09:52:02.467: D/dalvikvm(534): Not late-enabling CheckJNI (already on)
03-21 09:52:04.738: W/System.err(534): =====================================================================================
03-21 09:52:04.738: W/System.err(534): ERROR: plugin.xml is missing. Add res/xml/plugins.xml to your project.
03-21 09:52:04.738: W/System.err(534): https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.git;a=blob;f=framework/res/xml/plugins.xml
03-21 09:52:04.738: W/System.err(534): =====================================================================================
03-21 09:52:04.738: W/ResourceType(534): No package identifier when getting value for resource number 0x00000000
03-21 09:52:04.748: D/AndroidRuntime(534): Shutting down VM
03-21 09:52:04.748: W/dalvikvm(534): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
03-21 09:52:04.758: W/System.err(534): java.net.SocketException: socket failed: EACCES (Permission denied)
03-21 09:52:04.768: W/System.err(534): at libcore.io.IoBridge.socket(IoBridge.java:573)
03-21 09:52:04.768: W/System.err(534): at java.net.PlainSocketImpl.create(PlainSocketImpl.java:201)
03-21 09:52:04.768: W/System.err(534): at java.net.PlainServerSocketImpl.create(PlainServerSocketImpl.java:38)
03-21 09:52:04.778: W/System.err(534): at java.net.ServerSocket.<init>(ServerSocket.java:98)
03-21 09:52:04.788: W/System.err(534): at java.net.ServerSocket.<init>(ServerSocket.java:69)
03-21 09:52:04.788: W/System.err(534): at org.apache.cordova.CallbackServer.run(CallbackServer.java:208)
03-21 09:52:04.788: W/System.err(534): at java.lang.Thread.run(Thread.java:856)
03-21 09:52:04.788: W/System.err(534): Caused by: libcore.io.ErrnoException: socket failed: EACCES (Permission denied)
03-21 09:52:04.788: W/System.err(534): at libcore.io.Posix.socket(Native Method)
03-21 09:52:04.788: W/System.err(534): at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:181)
03-21 09:52:04.788: W/System.err(534): at libcore.io.IoBridge.socket(IoBridge.java:558)
03-21 09:52:04.788: W/System.err(534): ... 6 more
03-21 09:52:04.817: E/AndroidRuntime(534): FATAL EXCEPTION: main
03-21 09:52:04.817: E/AndroidRuntime(534): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.phonegap.helloworld/com.phonegap.helloworld.app}: android.content.res.Resources$NotFoundException: Resource ID #0x0
03-21 09:52:04.817: E/AndroidRuntime(534): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
03-21 09:52:04.817: E/AndroidRuntime(534): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-21 09:52:04.817: E/AndroidRuntime(534): at android.app.ActivityThread.access$600(ActivityThread.java:123)
03-21 09:52:04.817: E/AndroidRuntime(534): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-21 09:52:04.817: E/AndroidRuntime(534): at android.os.Handler.dispatchMessage(Handler.java:99)
03-21 09:52:04.817: E/AndroidRuntime(534): at android.os.Looper.loop(Looper.java:137)
03-21 09:52:04.817: E/AndroidRuntime(534): at android.app.ActivityThread.main(ActivityThread.java:4424)
03-21 09:52:04.817: E/AndroidRuntime(534): at java.lang.reflect.Method.invokeNative(Native Method)
03-21 09:52:04.817: E/AndroidRuntime(534): at java.lang.reflect.Method.invoke(Method.java:511)
03-21 09:52:04.817: E/AndroidRuntime(534): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-21 09:52:04.817: E/AndroidRuntime(534): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-21 09:52:04.817: E/AndroidRuntime(534): at dalvik.system.NativeStart.main(Native Method)
03-21 09:52:04.817: E/AndroidRuntime(534): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
03-21 09:52:04.817: E/AndroidRuntime(534): at android.content.res.Resources.getValue(Resources.java:1019)
03-21 09:52:04.817: E/AndroidRuntime(534): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2107)
03-21 09:52:04.817: E/AndroidRuntime(534): at android.content.res.Resources.getXml(Resources.java:907)
03-21 09:52:04.817: E/AndroidRuntime(534): at org.apache.cordova.api.PluginManager.loadPlugins(PluginManager.java:82)
03-21 09:52:04.817: E/AndroidRuntime(534): at org.apache.cordova.api.PluginManager.<init>(PluginManager.java:62)
03-21 09:52:04.817: E/AndroidRuntime(534): at org.apache.cordova.DroidGap$1.run(DroidGap.java:502)
03-21 09:52:04.817: E/AndroidRuntime(534): at android.app.Activity.runOnUiThread(Activity.java:4170)
03-21 09:52:04.817: E/AndroidRuntime(534): at org.apache.cordova.DroidGap.loadUrlIntoView(DroidGap.java:478)
03-21 09:52:04.817: E/AndroidRuntime(534): at org.apache.cordova.DroidGap.loadUrl(DroidGap.java:444)
03-21 09:52:04.817: E/AndroidRuntime(534): at com.phonegap.helloworld.app.onCreate(app.java:15)
03-21 09:52:04.817: E/AndroidRuntime(534): at android.app.Activity.performCreate(Activity.java:4465)
03-21 09:52:04.817: E/AndroidRuntime(534): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
03-21 09:52:04.817: E/AndroidRuntime(534): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
03-21 09:52:04.817: E/AndroidRuntime(534): ... 11 more
console:
[2012-03-21 09:49:28 - HelloPhoneGap] ------------------------------
[2012-03-21 09:49:28 - HelloPhoneGap] Android Launch!
[2012-03-21 09:49:28 - HelloPhoneGap] adb is running normally.
[2012-03-21 09:49:28 - HelloPhoneGap] Performing com.phonegap.helloworld.app activity launch
[2012-03-21 09:49:28 - HelloPhoneGap] Automatic Target Mode: launching new emulator with compatible AVD 'avd'
[2012-03-21 09:49:28 - HelloPhoneGap] Launching a new emulator with Virtual Device 'avd'
[2012-03-21 09:49:39 - Emulator] emulator: WARNING: Unable to create sensors port: Connection refused
[2012-03-21 09:49:39 - Emulator] emulator: emulator window was out of view and was recentered
[2012-03-21 09:49:39 - Emulator]
[2012-03-21 09:49:41 - HelloPhoneGap] New emulator found: emulator-5554
[2012-03-21 09:49:41 - HelloPhoneGap] Waiting for HOME ('android.process.acore') to be launched...
[2012-03-21 09:51:23 - HelloPhoneGap] HOME is up on device 'emulator-5554'
[2012-03-21 09:51:23 - HelloPhoneGap] Uploading HelloPhoneGap.apk onto device 'emulator-5554'
[2012-03-21 09:51:24 - HelloPhoneGap] Installing HelloPhoneGap.apk...
[2012-03-21 09:52:02 - HelloPhoneGap] Success!
[2012-03-21 09:52:02 - HelloPhoneGap] Starting activity com.phonegap.helloworld.app on device emulator-5554
[2012-03-21 09:52:04 - HelloPhoneGap] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.phonegap.helloworld/.app }
can anyone can help me about my case?
The fix that worked for me was to copy the file 'config.xml' from the Cordova download zip (lib/android/example/res/xml/config.xml) into my project's res/xml folder. I ran into this same error, working through the Cordova 2.0.0 Getting Started with Android page. The file plugin.xml does not appear to be in Cordova 2.0.0 (at least in the Android branch). The error to logcat still mentions it however.
1) In onCreate method did you initialize like super.init(); if not do
2) check plugins present in this path "xml/res/plugins.xml" if not find plugins here
Note: put that plugins tag inside cordova like <cordova> <plugins> <plugin> </plugins> </cordova>

inflating fragments with compatibility package android

I am trying to inflate a layout containing a Fragment using the backwards compatibility package. I took the jar file and placed it in the libs folder of my project. I extended Fragment and then tried to inflate it by setting the contentView of the Activity to
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<fragment
class="com.test.fragments.AdFragment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/></LinearLayout>
But when I set the content view it fails with a ClassNotFoundException for the fragment tag.
Here is the logcat output.
java.lang.RuntimeException: Unable to start activity ComponentInfo{}: \
android.view.InflateException: Binary XML file line #51: \
Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1777)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1793)
at android.app.ActivityThread.access$1500(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3848)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #51: \
Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:211)
at android.app.Activity.setContentView(Activity.java:1657)
at com.test.base.activities.TabbedStoreActivity.onCreate(TabbedStoreActivity.java:46)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1731)
... 11 more
Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader \
dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar: \
/data/app/com.test.test.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.view.LayoutInflater.createView(LayoutInflater.java:471)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
... 20 more
Make sure your activity is inheriting from FragmentActivity, otherwise <fragment> does not work. Here is a sample project demonstrating this.

Categories

Resources