安卓公司。谷歌。ads.AdView未能实例化java。lang.ClassNotFoundException:org。json。JSONException
我正在接收com。谷歌。ads.AdView无法在我的主服务器上实例化消息。当我时钟显示消息时,我有以下内容,它说找不到源。对不起,我不是一个好的开发者,我只是通过观看视频来学习创建我的应用程序。我使用的是安卓4.4.2
Error
Fri Apr 18 13:11:54 BST 2014
com.google.ads.AdView failed to instantiate.
java.lang.ClassNotFoundException: org.json.JSONException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.google.ads.AdView.a(SourceFile:184)
at com.google.ads.AdView.a(SourceFile:352)
at com.google.ads.AdView.<init>(SourceFile:125)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.安卓.ide.eclipse.adt.internal.editors.layout.ProjectCallback.instantiateClass(ProjectCallback.java:437)
at com.安卓.ide.eclipse.adt.internal.editors.layout.ProjectCallback.loadView(ProjectCallback.java:189)
at 安卓.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at 安卓.view.BridgeInflater.createViewFromTag(BridgeInflater.java:135)
at 安卓.view.LayoutInflater.rInflate_Original(LayoutInflater.java:755)
at 安卓.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at 安卓.view.LayoutInflater.rInflate(LayoutInflater.java:727)
at 安卓.view.LayoutInflater.inflate(LayoutInflater.java:492)
at 安卓.view.LayoutInflater.inflate(LayoutInflater.java:373)
at com.安卓.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:399)
at com.安卓.layoutlib.bridge.Bridge.createSession(Bridge.java:336)
at com.安卓.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:332)
at com.安卓.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:504)
at com.安卓.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1584)
at com.安卓.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1309)
at com.安卓.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.changed(GraphicalEditorPart.java:725)
at com.安卓.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.onTargetChange(GraphicalEditorPart.java:1196)
at com.安卓.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate.onDescriptorsChanged(LayoutEditorDelegate.java:916)
at com.安卓.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate.delegateInitUiRootNode(LayoutEditorDelegate.java:835)
at com.安卓.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart$TargetListener.updateEditor(GraphicalEditorPart.java:953)
at com.安卓.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart$TargetListener.onTargetLoaded(GraphicalEditorPart.java:917)
at com.安卓.ide.eclipse.adt.AdtPlugin$11.run(AdtPlugin.java:1759)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4145)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3762)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
我的主菜。xml是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:ads="http://schemas.安卓.com/apk/lib/com.google.ads"
安卓:layout_width="fill_parent"
安卓:layout_height="fill_parent"
安卓:background="@drawable/splash_background"
安卓:keepScreenOn="true"
安卓:orientation="vertical" >
<TextView
安卓:id="@+id/tvDisplay"
安卓:layout_width="fill_parent"
安卓:layout_height="wrap_content"
安卓:layout_gravity="center"
安卓:gravity="center"
安卓:textColor="#58ACFA"
安卓:textSize="30sp" />
<Button
安卓:id="@+id/bStart"
安卓:layout_width="150dp"
安卓:layout_height="40dp"
安卓:layout_gravity="center"
安卓:layout_marginTop="20dp"
安卓:text="@string/start"
安卓:textSize="15sp" />
<TextView
安卓:id="@+id/timerValue"
安卓:layout_width="fill_parent"
安卓:layout_height="wrap_content"
安卓:layout_gravity="center"
安卓:gravity="center"
安卓:text="@string/timerVal"
安卓:textColor="#58ACFA"
安卓:textSize="25sp" />
<Button
安卓:id="@+id/bDur"
安卓:layout_width="150dp"
安卓:layout_height="40dp"
安卓:layout_gravity="center"
安卓:text="@string/stop"
安卓:textSize="15sp" />
<com.google.ads.AdView
安卓:id="@+id/ad"
安卓:layout_marginTop="90dp"
安卓:layout_width="fill_parent"
安卓:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="My ID"
ads:loadAdOnCreate="true"
ads:layout_alignParentBottom="true"
/>
</LinearLayout>
还有我的mainfest。xml是:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
package="com.kolik.kolikbebek"
安卓:versionCode="1"
安卓:versionName="1.0" >
<uses-sdk
安卓:minSdkVersion="13"
安卓:targetSdkVersion="19" />
<uses-permission 安卓:name="安卓.permission.INTERNET"/>
<uses-permission 安卓:name="安卓.permission.ACCESS_NETWORK_STATE"/>
<application
安卓:allowBackup="true"
安卓:icon="@drawable/ic_launcher"
安卓:label="@string/app_name"
安卓:theme="@style/AppTheme"
>
<activity 安卓:name=".Splash" > <!-- label comment at the begin安卓:label="@string/app_name"-->
<intent-filter>
<action 安卓:name="安卓.intent.action.MAIN" />
<category 安卓:name="安卓.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
安卓:name=".AnneSesi" 安卓:label="@string/app_name">
<intent-filter>
<action 安卓:name="com.kolik.kolikbebek.ANNESESI" />
<category 安卓:name="安卓.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
安卓:name=".SupurgeSesi" 安卓:label="@string/app_name">
<intent-filter>
<action 安卓:name="com.kolik.kolikbebek.SUPURGESESI" />
<category 安卓:name="安卓.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
安卓:name=".MainActivity" 安卓:label="@string/app_name" >
<intent-filter>
<action 安卓:name="com.kolik.kolikbebek.MAINACTIVITY" />
<category 安卓:name="安卓.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
安卓:name=".Menu" 安卓:label="@string/app_name" >
<intent-filter>
<action 安卓:name="com.kolik.kolikbebek.MENU" />
<category 安卓:name="安卓.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity 安卓:name="com.google.ads.AdActivity"
安卓:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
</manifest>
我的Java代码是:
public class MainActivity extends Activity {
private Button start, stop;
private MediaPlayer mp;
private TextView timerValue, display;
private long startTime = 0L;
private Handler customHandler = new Handler();
long timeInMilliseconds = 0L;
long timeSwapBuff = 0L;
long updatedTime = 0L;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
display = (TextView)findViewById(R.id.tvDisplay);
display.setText("Kurutma");
timerValue = (TextView) findViewById(R.id.timerValue);
start = (Button) findViewById(R.id.bStart);
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mp = MediaPlayer.create(MainActivity.this, R.raw.elektirikli);
mp.setLooping(true);
mp.start();
//mp.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);
startTime = SystemClock.uptimeMillis();
customHandler.postDelayed(updateTimerThread, 0);
mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
mp.stop();
mp.reset();
mp.release(); // free up memory
mp = null;
}
});
}
});
stop = (Button) findViewById(R.id.bDur);
stop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mp != null) {
try {
mp.stop();
mp.reset();
mp.release();
mp = null;
} catch (Exception e) {
Log.d("error", e.toString());
}
}
timeSwapBuff += timeInMilliseconds;
customHandler.removeCallbacks(updateTimerThread);
}
});
}
@Override
protected void onPause() {
if (mp != null && mp.isPlaying()) {
mp.stop();
}
super.onPause();
customHandler.removeCallbacks(updateTimerThread);
}
private Runnable updateTimerThread = new Runnable() {
public void run() {
timeInMilliseconds = SystemClock.uptimeMillis() - startTime;
updatedTime = timeSwapBuff + timeInMilliseconds;
int secs = (int) (updatedTime / 1000);
int mins = secs / 60;
secs = secs % 60;
// int milliseconds = (int) (updatedTime % 1000);
timerValue.setText("" + mins + ":" + String.format("%02d", secs));
customHandler.postDelayed(this, 0);
}
};
}
# 1 楼答案
您发布的错误是来自Eclipse IDE的错误。也就是说,这是一个开发时错误,而不是运行时错误
这意味着您没有在Eclipse中正确配置Android SDK的路径
在Eclipse转到窗口内->;偏好->;Android并浏览到SDK文件夹