本文介绍了Adwhril样品例如给予ClassNotFound的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我这样的清单文件
i am having my manifest file like this
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.basic.adwhrilsample"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name=".Invoker" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:value="my sdk key"
android:name="ADWHIRL_KEY"/>
</activity>
</application>
和下面的是我的main.xml文件
and the below is my main.xml file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/layout_main">
<com.adwhirl.AdWhirlLayout
android:id="@+id/adwhirl_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
和我Invoker.java活动
and my Invoker.java activity
package com.basic.adwhrilsample;
import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import com.adwhirl.AdWhirlLayout;
import com.adwhirl.AdWhirlLayout.AdWhirlInterface;
import com.adwhirl.AdWhirlManager;
import com.adwhirl.AdWhirlTargeting;
public class Invoker extends Activity implements AdWhirlInterface {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AdWhirlManager.setConfigExpireTimeout(1000 * 60 * 5);
AdWhirlTargeting.setAge(23);
AdWhirlTargeting.setGender(AdWhirlTargeting.Gender.MALE);
AdWhirlTargeting.setKeywords("online games gaming");
AdWhirlTargeting.setPostalCode("94123");
AdWhirlTargeting.setTestMode(false);
AdWhirlLayout adWhirlLayout = (AdWhirlLayout)
findViewById(R.id.adwhirl_layout);
TextView textView = new TextView(this);
RelativeLayout.LayoutParams layoutParams = new
RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
int diWidth = 320;
int diHeight = 52;
int density = (int) getResources().getDisplayMetrics().density;
adWhirlLayout.setAdWhirlInterface(this);
adWhirlLayout.setMaxWidth((int) (diWidth * density));
adWhirlLayout.setMaxHeight((int) (diHeight * density));
layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
textView.setText("Below AdWhirlLayout");
LinearLayout layout = (LinearLayout) findViewById(R.id.layout_main);
layout.setGravity(Gravity.CENTER_HORIZONTAL);
layout.addView(adWhirlLayout, layoutParams);
layout.addView(textView, layoutParams);
layout.invalidate();
}
@Override
public void adWhirlGeneric() {
}
}
但我正在逐渐
08-30 10:17:25.194: E/AndroidRuntime(564): java.lang.RuntimeException: Unable to
instantiate activity
ComponentInfo{com.basic.adwhrilsample/com.basic.adwhrilsample.Invoker}:
java.lang.ClassNotFoundException: com.basic.adwhrilsample.Invoker in loader
dalvik.system.PathClassLoader[/data/app/com.basic.adwhrilsample-2.apk]
谁能帮我解决我的问题。
或者,任何人都可以提供我一个样品工作的例子,这样我可以跟随它
Can anyone help me out in solving my issue.Or can anyone provide me a sample working example so that i could follow it
更新logcat的:
推荐答案
我觉得一切都还好吧只是替代进口包替换此
i think everything is allright just replace imported package replace this
import android.widget.RelativeLayout.LayoutParams;
按
import android.view.ViewGroup.LayoutParams;
这篇关于Adwhril样品例如给予ClassNotFound的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!