NoClassDefFoundError: AdWhirlLayout - android

i checked similar question on the forum, but couldn't get it to run.
Finally i removed everything not needed to focused on the error and i left with that chunk of code. But it's still crashing with a NoClassDefFoundError at the
AdWhirlLayout adWhirlLayout = new AdWhirlLayout(TestActivity.this, key);
line.
I'am using AdWhirlSDK_Android_3.1.1 but tried as well the AdWhirlSDK_Android_3.0.0. I've got the same error.
Java Code.
import com.adwhirl.AdWhirlLayout;
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.LinearLayout.LayoutParams;
public class TestActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setupAds();
}
private void setupAds() {
String key = "adwhirl_key";
int diWidth = 320;
int diHeight = 52;
float density = getResources().getDisplayMetrics().density;
LinearLayout layout = (LinearLayout) findViewById(R.id.adView);
RelativeLayout.LayoutParams layoutParams =
new RelativeLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
AdWhirlLayout adWhirlLayout = new AdWhirlLayout(TestActivity.this, key);
adWhirlLayout.setMaxWidth((int) (diWidth * density));
adWhirlLayout.setMaxHeight((int) (diHeight * density));
layout.addView(adWhirlLayout, layoutParams);
layout.invalidate();
}
}
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" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/hello" />
<LinearLayout
android:id="#+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
LOGCAT:
04-11 17:59:50.451: E/AndroidRuntime(707): FATAL EXCEPTION: main
04-11 17:59:50.451: E/AndroidRuntime(707): java.lang.NoClassDefFoundError: com.adwhirl.AdWhirlLayout
04-11 17:59:50.451: E/AndroidRuntime(707): at com.testproject.TestActivity.setupAds(TestActivity.java:34)
04-11 17:59:50.451: E/AndroidRuntime(707): at com.testproject.TestActivity.onCreate(TestActivity.java:18)
04-11 17:59:50.451: E/AndroidRuntime(707): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-11 17:59:50.451: E/AndroidRuntime(707): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-11 17:59:50.451: E/AndroidRuntime(707): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-11 17:59:50.451: E/AndroidRuntime(707): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-11 17:59:50.451: E/AndroidRuntime(707): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-11 17:59:50.451: E/AndroidRuntime(707): at android.os.Handler.dispatchMessage(Handler.java:99)
04-11 17:59:50.451: E/AndroidRuntime(707): at android.os.Looper.loop(Looper.java:123)
04-11 17:59:50.451: E/AndroidRuntime(707): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-11 17:59:50.451: E/AndroidRuntime(707): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 17:59:50.451: E/AndroidRuntime(707): at java.lang.reflect.Method.invoke(Method.java:507)
04-11 17:59:50.451: E/AndroidRuntime(707): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-11 17:59:50.451: E/AndroidRuntime(707): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-11 17:59:50.451: E/AndroidRuntime(707): at dalvik.system.NativeStart.main(Native Method)
Has anybody an idea and can tell my what i cant see.Please.
Best Regards

You should definitely check the link in your comments. Basically you need to handle all of your dependencies in android by putting the required libraries in a "libs" folder. Eclipse doesn't generate this automatically for you, so you have to make it yourself. Put the "libs" folder in the "res" folder (not bin/res, the res folder that shares the same directory as src).
Also make sure you have all the proper declarations in your manifest if you are launching other activities, need special permissions for those functions (uses-internet), etc.

Go to your project that uses .jar files (i.e. project under test). Click right button -> Properties-> Java Build Path -> Order and Export -> check libraries there. Check this link for the screenshot.

Related

Android dialogs are causing android.view.WindowManager$BadTokenException: Unable to add window

I have putted my activities in childview and now I cannot display dialogs from my activities and adapters. In my logCat i'm getting
04-11 12:39:59.823: E/AndroidRuntime(12831): FATAL EXCEPTION: main
04-11 12:39:59.823: E/AndroidRuntime(12831): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord#41971f18 is not valid; is your activity running?
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.view.ViewRootImpl.setView(ViewRootImpl.java:513)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:301)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.view.Window$LocalWindowManager.addView(Window.java:537)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.app.Dialog.show(Dialog.java:278)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.app.AlertDialog$Builder.show(AlertDialog.java:932)
04-11 12:39:59.823: E/AndroidRuntime(12831): at com.myapp.functions.DownloadsDetailsAdapter$1$2.run(DownloadsDetailsAdapter.java:148)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.app.Activity.runOnUiThread(Activity.java:4170)
04-11 12:39:59.823: E/AndroidRuntime(12831): at com.myapp.functions.DownloadsDetailsAdapter$1.onClick(DownloadsDetailsAdapter.java:139)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.view.View.performClick(View.java:3511)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.view.View$PerformClick.run(View.java:14105)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.os.Handler.handleCallback(Handler.java:605)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.os.Handler.dispatchMessage(Handler.java:92)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.os.Looper.loop(Looper.java:137)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.app.ActivityThread.main(ActivityThread.java:4440)
04-11 12:39:59.823: E/AndroidRuntime(12831): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 12:39:59.823: E/AndroidRuntime(12831): at java.lang.reflect.Method.invoke(Method.java:511)
04-11 12:39:59.823: E/AndroidRuntime(12831): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
04-11 12:39:59.823: E/AndroidRuntime(12831): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
04-11 12:39:59.823: E/AndroidRuntime(12831): at dalvik.system.NativeStart.main(Native Method)
And here is an example of how I'm trying to display dialogs.
AlertDialog.Builder builder = new AlertDialog.Builder(
activity);
builder.setMessage(R.string.are_you_sure)
.setPositiveButton(R.string.yes,
dialogClickListener)
.setNegativeButton(R.string.no, dialogClickListener)
.show();
Note: this code was working before I make the change. I thing I should run this in new runnable but if should I have to do that, can anybody tell me how can I do that?
I also faced the same problem. I have used tab bar for this. Just use getParent() instead of youractivity.this.
I hope this will help.
the activity object must be the activity that is currently shown on the screen.
If it's something that was already paused or not build show yet it will give this error.
see here the answer for ActivityGroup.
For child activity of a ActivityGroup, we cannot be sure that it always exist and live when we use the Context in the child activity such as PrompDialog.
For example:
mPromptDialog = new LoginPromptDialog(this);//this is used as Context
//But when we use this context it may be destroyed.
//So this is the parent instance
mPromptDialog = new LoginPromptDialog(this.getParent());
preference:
http://www.cnblogs.com/kaima/archive/2011/08/04/2127813.html

App crashes saying that a library is not included, even though it is

My Android app seemed to have been working fine till i did a git reset on it. Now it keep crashing and says that a library I am using is not present.
This is the crash log I get
04-11 16:31:31.230: E/AndroidRuntime(9206): FATAL EXCEPTION: main
04-11 16:31:31.230: E/AndroidRuntime(9206): java.lang.NoClassDefFoundError: de.greenrobot.event.EventBus$3
04-11 16:31:31.230: E/AndroidRuntime(9206): at de.greenrobot.event.EventBus.postToSubscription(EventBus.java:413)
04-11 16:31:31.230: E/AndroidRuntime(9206): at de.greenrobot.event.EventBus.postSingleEvent(EventBus.java:399)
04-11 16:31:31.230: E/AndroidRuntime(9206): at de.greenrobot.event.EventBus.post(EventBus.java:326)
04-11 16:31:31.230: E/AndroidRuntime(9206): at com.cobboc.eashmartdemo.Session$5.onError(Session.java:362)
04-11 16:31:31.230: E/AndroidRuntime(9206): at com.cobboc.eashmartdemo.Session$5.onSuccess(Session.java:355)
04-11 16:31:31.230: E/AndroidRuntime(9206): at com.cobboc.eashmartdemo.Session$3.run(Session.java:238)
04-11 16:31:31.230: E/AndroidRuntime(9206): at android.os.Handler.handleCallback(Handler.java:615)
04-11 16:31:31.230: E/AndroidRuntime(9206): at android.os.Handler.dispatchMessage(Handler.java:92)
04-11 16:31:31.230: E/AndroidRuntime(9206): at android.os.Looper.loop(Looper.java:137)
04-11 16:31:31.230: E/AndroidRuntime(9206): at android.app.ActivityThread.main(ActivityThread.java:4931)
04-11 16:31:31.230: E/AndroidRuntime(9206): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 16:31:31.230: E/AndroidRuntime(9206): at java.lang.reflect.Method.invoke(Method.java:511)
04-11 16:31:31.230: E/AndroidRuntime(9206): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
04-11 16:31:31.230: E/AndroidRuntime(9206): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
04-11 16:31:31.230: E/AndroidRuntime(9206): at dalvik.system.NativeStart.main(Native Method)
I have tried restoring the last known working copy too. Could it be an issue with my machine?
You need to make sure that the library is in the app libs directory
Look in eclipse - make sure you have a libs directory and that the library is in it
It turns out that I was using new relic to build the app, and when I used eclipse to build it, the libraries failed.

Google Maps Android API v2 and Eclipse

I am new in Google Map and so many things aren't clear enough to me for that reason.So i expect some expert's direction on this regard.I read This Guide and did everything what it says.I use google map api v2 and get a map key.Then i make a sample project following that link and select target version android 2.2(while running the project).But a list of error occurs after running then example in eclipse android emulator.My logcat view shows:
01-31 00:51:59.226: W/dalvikvm(329): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
01-31 00:51:59.236: E/AndroidRuntime(329): FATAL EXCEPTION: main
01-31 00:51:59.236: E/AndroidRuntime(329): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.googleMapApp/com.googleMapApp.LocationProfileManagerActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
01-31 00:51:59.236: E/AndroidRuntime(329): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.os.Handler.dispatchMessage(Handler.java:99)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.os.Looper.loop(Looper.java:123)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-31 00:51:59.236: E/AndroidRuntime(329): at java.lang.reflect.Method.invokeNative(Native Method)
01-31 00:51:59.236: E/AndroidRuntime(329): at java.lang.reflect.Method.invoke(Method.java:521)
01-31 00:51:59.236: E/AndroidRuntime(329): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-31 00:51:59.236: E/AndroidRuntime(329): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-31 00:51:59.236: E/AndroidRuntime(329): at dalvik.system.NativeStart.main(Native Method)
01-31 00:51:59.236: E/AndroidRuntime(329): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
01-31 00:51:59.236: E/AndroidRuntime(329): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-31 00:51:59.236: E/AndroidRuntime(329): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.app.Activity.setContentView(Activity.java:1647)
01-31 00:51:59.236: E/AndroidRuntime(329): at com.googleMapApp.LocationProfileManagerActivity.onCreate(LocationProfileManagerActivity.java:14)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
01-31 00:51:59.236: E/AndroidRuntime(329): ... 11 more
01-31 00:51:59.236: E/AndroidRuntime(329): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.googleMapApp-1.apk]
01-31 00:51:59.236: E/AndroidRuntime(329): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
01-31 00:51:59.236: E/AndroidRuntime(329): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
01-31 00:51:59.236: E/AndroidRuntime(329): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
01-31 00:51:59.236: E/AndroidRuntime(329): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
01-31 00:51:59.236: E/AndroidRuntime(329): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
My Manifest.xml is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.googleMapApp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<permission
android:name="com.googleMapApp.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.googleMapApp.permission.MAPS_RECEIVE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- Require OpenGL ES version 2 -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".LocationProfileManagerActivity"
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="myMapKey"/>
</application>
</manifest>
My main.xml is:
<?xml version="1.0" encoding="utf-8"?>
<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.MapFragment"/>
My activity.java is:
package com.googleMapApp;
import android.app.Activity;
import android.os.Bundle;
public class LocationProfileManagerActivity extends Activity {
/** Called when the activity is first created. */
//private GoogleMap map;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
}
}
Sorry for this lengthy description,but i want to show you exactly what i did.I think as a newcomer i did a lot of mistake on this way.so i expect someone will guide me that.
You are using features only available in later APIs, namely Fragment. If you want to compile to support 2.2, you need to include the Support Library in your project. You will also have to make the following changes to use support fragments instead of regular fragments --
In main.xml, change
class="com.google.android.gms.maps.MapFragment"/>
to
class="com.google.android.gms.maps.SupportMapFragment"/>
and in your activity.java, change
public class LocationProfileManagerActivity extends Activity {
to
public class LocationProfileManagerActivity extends FragmentActivity {
you need to make two changes
Since as you are sdk version is below 12, need to make following change
1)
main.xml
Replace
class="com.google.android.gms.maps.MapFragment"/>
with
class="com.google.android.gms.maps.SupportMapFragment"/>
2) activity.java
Need to extend FragmentActivity instead of Activity
If you want to test in emulator , then download the google_play_services_apk and install it in emulator.
Maps API v2 cannot be run in an emulator because of its dependency on Google Play Services, which is bundled in the Google Play Store .apk. It can be hacked together though, you can read about it here on the first Google result for "Google maps v2 emulator". Also you can still use V1 for a limited time, you can get started here.

getting Fatal Exception caused by admob

I have an app on the market using admob and now I would like to update my app. When I test this new version I get a Fatal Exception caused by the admob.
04-06 15:09:04.123: E/AndroidRuntime(409): Caused by: android.view.InflateException: Binary XML file line #51: Error inflating class com.google.ads.AdView
04-06 15:09:04.123: E/AndroidRuntime(409): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView in loader dalvik.system.PathClassLoader[/data/app/com.kmbdev.purrkitty-2.apk]
Here is the xml file with line #51:
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/bottom_border"
android:layout_toLeftOf="#id/right_border"
ads:adSize="BANNER"
ads:adUnitId="my id"
ads:loadAdOnCreate="true" />
I have not made any major changes from the original app that is published. I have only added a splash screen and some language strings files and changed the version to 1.2, the published app is version 1.1. I was wondering why this app will no longer run.
I have tried again, here is the log:
04-11 12:13:21.474: D/AndroidRuntime(282): Shutting down VM
04-11 12:13:21.474: W/dalvikvm(282): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-11 12:13:21.644: E/AndroidRuntime(282): FATAL EXCEPTION: main
04-11 12:13:21.644: E/AndroidRuntime(282): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kmbdev.purrkitty/com.kmbdev.purrkitty.Cat1}: android.view.InflateException: Binary XML file line #52: Error inflating class com.google.ads.AdView
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.os.Handler.dispatchMessage(Handler.java:99)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.os.Looper.loop(Looper.java:123)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-11 12:13:21.644: E/AndroidRuntime(282): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 12:13:21.644: E/AndroidRuntime(282): at java.lang.reflect.Method.invoke(Method.java:521)
04-11 12:13:21.644: E/AndroidRuntime(282): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-11 12:13:21.644: E/AndroidRuntime(282): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-11 12:13:21.644: E/AndroidRuntime(282): at dalvik.system.NativeStart.main(Native Method)
04-11 12:13:21.644: E/AndroidRuntime(282): Caused by: android.view.InflateException: Binary XML file line #52: Error inflating class com.google.ads.AdView
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-11 12:13:21.644: E/AndroidRuntime(282): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.Activity.setContentView(Activity.java:1647)
04-11 12:13:21.644: E/AndroidRuntime(282): at com.kmbdev.purrkitty.Cat1.onCreate(Cat1.java:25)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-11 12:13:21.644: E/AndroidRuntime(282): ... 11 more
04-11 12:13:21.644: E/AndroidRuntime(282): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView in loader dalvik.system.PathClassLoader[/data/app/com.kmbdev.purrkitty-2.apk]
04-11 12:13:21.644: E/AndroidRuntime(282): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-11 12:13:21.644: E/AndroidRuntime(282): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-11 12:13:21.644: E/AndroidRuntime(282): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
04-11 12:13:21.644: E/AndroidRuntime(282): ... 20 more
I've got the same issue and wasted more than 3 hours to figure it out. Finally, I found the way to make it work.
change sdk name from GoogleAdMobAdsSdk-6.0.0.jar to GoogleAdMobAdsSdk.jar
create "libs" folder under project, copy above sdk in the folder and link the library using Add External JARs.
if not worked, change import class name from com.google.ads.* to com.google.ads.AdRequest, comp.google.ads.AdView, and so on.
Are you sure the manifest has all the tags? (Those of admob). Also in the XML, you need to have a addl tag for xmlns right? Did you specify it?
Clean your project, and if you don't have activated the automatic build in Eclipse, make a manual build. It will work.
To fix that problem you just have to link the sdk .jar file in two ways. First, to add it to the libs folder (if you don't have one, create it) and then, right-click on .jar file, go to Build Path->Add to Build Path... Three days to that conclusion.
I fixed it by renaming the folder in which the jar file is kept from /lib to /libs.

imageview fadeineffect not working

I've been practicing some animation on Android but I could not get my code to work. the application fails at launch. Here is my main class + fade in class,
can you help me find out the problem?
package send.Shift;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
public class ShiftsActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView Arrow = (ImageView) findViewById(R.drawable.arrow);
Animation fadeInAnimation = AnimationUtils.loadAnimation(this,
R.anim.fade_in);
// Now Set your animation
Arrow.startAnimation(fadeInAnimation);
}
}
XML:
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/accelerate_interpolator"
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="500" />
logcat:
12-16 03:40:23.863: D/AndroidRuntime(707): Shutting down VM
12-16 03:40:23.863: W/dalvikvm(707): threadid=1: thread exiting with uncaught exception (group=0x40015560)
12-16 03:40:23.873: E/AndroidRuntime(707): FATAL EXCEPTION: main
12-16 03:40:23.873: E/AndroidRuntime(707): java.lang.RuntimeException: Unable to start activity ComponentInfo{send.Shift/send.Shift.ShiftsActivity}: java.lang.NullPointerException
12-16 03:40:23.873: E/AndroidRuntime(707): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
12-16 03:40:23.873: E/AndroidRuntime(707): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
12-16 03:40:23.873: E/AndroidRuntime(707): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-16 03:40:23.873: E/AndroidRuntime(707): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
12-16 03:40:23.873: E/AndroidRuntime(707): at android.os.Handler.dispatchMessage(Handler.java:99)
12-16 03:40:23.873: E/AndroidRuntime(707): at android.os.Looper.loop(Looper.java:123)
12-16 03:40:23.873: E/AndroidRuntime(707): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-16 03:40:23.873: E/AndroidRuntime(707): at java.lang.reflect.Method.invokeNative(Native Method)
12-16 03:40:23.873: E/AndroidRuntime(707): at java.lang.reflect.Method.invoke(Method.java:507)
12-16 03:40:23.873: E/AndroidRuntime(707): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-16 03:40:23.873: E/AndroidRuntime(707): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-16 03:40:23.873: E/AndroidRuntime(707): at dalvik.system.NativeStart.main(Native Method)
12-16 03:40:23.873: E/AndroidRuntime(707): Caused by: java.lang.NullPointerException
12-16 03:40:23.873: E/AndroidRuntime(707): at send.Shift.ShiftsActivity.onCreate(ShiftsActivity.java:21)
12-16 03:40:23.873: E/AndroidRuntime(707): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-16 03:40:23.873: E/AndroidRuntime(707): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
12-16 03:40:23.873: E/AndroidRuntime(707): ... 11 more
R.drawable.arrow cannot be an id of an imageview. That's a drawable, as in some picture you saved (png, or jpg) in your drawable folder. What you need is something like R.id.my_image_view
Try like this,
ImageView imageView= (ImageView)findViewById(R.id.imageView);
Animation fadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.your_fade_in_anim);
//Now Set your animation
imageView.startAnimation(fadeInAnimation );

Categories

Resources