gpt4 book ai didi

android - java.lang.RuntimeException : Unable to instantiate activity ComponentInfo . ... java.lang.ClassNotFoundException 异常

转载 作者:太空宇宙 更新时间:2023-11-03 12:10:28 24 4
gpt4 key购买 nike

三天以来我一直在处理一个问题,我尝试阅读不同的答案,但没有帮助。有人也可以帮帮我吗!!我将 Ancdroid 应用程序编写为 restful web 服务的客户端。我可以毫无问题地从数据库中获取数据,但我的问题是我用来处理从数据库中获取的文件的 2 个 Activity 。

主要 Activity

public class MainActivity extends Activity  {



private static final String SERVICE_URL = "http://10.0.2.2:8080/.....";
private static final String TAG = "AndroidRESTClientActivity";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

public void retrieveSampleData(View vw) {
EditText idTxt = (EditText) findViewById(R.id.id_textfield);
String id = idTxt.getText().toString();
String sampleURL = SERVICE_URL +"daten/"+id ;

Log.d("getrespond()", "service calling");
String url =sampleURL;

RestClient client = new RestClient(url);

try{
client.Execute(RestClient.RequestMethod.GET,this.getApplicationContext());
}
catch (Exception e) {

String error = String.valueOf(e);
Log.d("**********client.Execute(RequestMethod.GET);***********",error);

}

try {

if(client.getResponseCode() == 200) {

Log.d("Response is 200", String.valueOf(client.getResponse().length()));
System.out.println(this.getFilesDir().getPath().toString());
File daten= client.getResponse();
System.out.println(daten.getName());

Toast.makeText(this.getApplicationContext(), "Responce is "+String.valueOf(client.getResponseCode()), 2000).show();

} else {
String error = String.valueOf(client.getResponse());
Log.d("Response*********** not 200 ************", String.valueOf(client.getResponse()));

}

}catch (Exception e) {
e.printStackTrace();
Log.d("EXCEPTIONI IS 3", e.toString());
// TODO: handle exception
}
startActivity(new Intent("android.intent.action.LINEGRAPH"));

我从主要开始的其他 Activity :

public class lineGraph extends Activity{



@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_line_graph);
}

@Override
protected void onResume() {
super.onResume();
if (mChartView == null) {
LinearLayout layout = (LinearLayout) findViewById(R.id.chart);
try {
mChartView = ChartFactory.getLineChartView(this, getDemoDataset(),
getDemoRenderer());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
layout.addView(mChartView, new LayoutParams
(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

} else {
mChartView.repaint();
}
}

list .xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.praktikum.androidcrestclient"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" >
</uses-permission>
<uses-permission android:name="android.permission.INTERNET" >
</uses-permission>
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.praktikum.androidcrestclient.LineGraph"
android:label="@string/title_activity_line_graph" >
<intent-filter>
<action android:name="android.intent.action.LINEGRAPH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="org.achartengine.GraphicalActivity"/>
</application>

</manifest>

这是我的 LogCat

10-08 09:23:10.140: D/AndroidRuntime(4706): Shutting down VM
10-08 09:23:10.140: W/dalvikvm(4706): threadid=1: thread exiting with uncaught exception (group=0x40015560)
10-08 09:23:10.161: E/AndroidRuntime(4706): FATAL EXCEPTION: main
10-08 09:23:10.161: E/AndroidRuntime(4706): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.praktikum.androidcrestclient/com.praktikum.androidcrestclient.LineGraph}: java.lang.ClassNotFoundException: com.praktikum.androidcrestclient.LineGraph in loader dalvik.system.PathClassLoader[/data/app/com.praktikum.androidcrestclient-1.apk]
10-08 09:23:10.161: E/AndroidRuntime(4706): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
10-08 09:23:10.161: E/AndroidRuntime(4706): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-08 09:23:10.161: E/AndroidRuntime(4706): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-08 09:23:10.161: E/AndroidRuntime(4706): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-08 09:23:10.161: E/AndroidRuntime(4706): at android.os.Handler.dispatchMessage(Handler.java:99)
10-08 09:23:10.161: E/AndroidRuntime(4706): at android.os.Looper.loop(Looper.java:123)
10-08 09:23:10.161: E/AndroidRuntime(4706): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-08 09:23:10.161: E/AndroidRuntime(4706): at java.lang.reflect.Method.invokeNative(Native Method)
10-08 09:23:10.161: E/AndroidRuntime(4706): at java.lang.reflect.Method.invoke(Method.java:507)
10-08 09:23:10.161: E/AndroidRuntime(4706): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-08 09:23:10.161: E/AndroidRuntime(4706): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-08 09:23:10.161: E/AndroidRuntime(4706): at dalvik.system.NativeStart.main(Native Method)
10-08 09:23:10.161: E/AndroidRuntime(4706): Caused by: java.lang.ClassNotFoundException: com.praktikum.androidcrestclient.LineGraph in loader dalvik.system.PathClassLoader[/data/app/com.praktikum.androidcrestclient-1.apk]
10-08 09:23:10.161: E/AndroidRuntime(4706): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
10-08 09:23:10.161: E/AndroidRuntime(4706): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
10-08 09:23:10.161: E/AndroidRuntime(4706): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
10-08 09:23:10.161: E/AndroidRuntime(4706): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
10-08 09:23:10.161: E/AndroidRuntime(4706): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
10-08 09:23:10.161: E/AndroidRuntime(4706): ... 11 more
10-08 09:23:10.180: W/ActivityManager(89): Force finishing activity com.praktikum.androidcrestclient/.LineGraph
10-08 09:23:10.180: W/ActivityManager(89): Force finishing activity com.praktikum.androidcrestclient/.MainActivity
10-08 09:23:10.690: W/ActivityManager(89): Activity pause timeout for HistoryRecord{4094eea0 com.praktikum.androidcrestclient/.LineGraph}
10-08 09:23:12.330: I/Process(4706): Sending signal. PID: 4706 SIG: 9
10-08 09:23:12.350: I/ActivityManager(89): Process com.praktikum.androidcrestclient (pid 4706) has died.
10-08 09:23:12.360: E/InputDispatcher(89): channel '4065ae98 com.praktikum.androidcrestclient/com.praktikum.androidcrestclient.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x8
10-08 09:23:12.360: E/InputDispatcher(89): channel '4065ae98 com.praktikum.androidcrestclient/com.praktikum.androidcrestclient.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
10-08 09:23:12.490: I/WindowManager(89): WIN DEATH: Window{4065ae98 com.praktikum.androidcrestclient/com.praktikum.androidcrestclient.MainActivity paused=true}
10-08 09:23:12.500: I/WindowManager(89): WIN DEATH: Window{406c1140 Toast paused=false}
10-08 09:23:12.600: W/InputManagerService(89): Got RemoteException sending setActive(false) notification to pid 4706 uid 10034
10-08 09:23:12.660: E/InputDispatcher(89): Received spurious receive callback for unknown input channel. fd=168, events=0x8
10-08 09:23:16.820: D/dalvikvm(396): GC_EXPLICIT freed 7K, 54% free 2537K/5511K, external 1625K/2137K, paused 43ms
10-08 09:23:21.626: W/ActivityManager(89): Activity destroy timeout for HistoryRecord{4094e768 com.praktikum.androidcrestclient/.MainActivity}
10-08 09:23:21.626: W/ActivityManager(89): Activity destroy timeout for HistoryRecord{4094eea0 com.praktikum.androidcrestclient/.LineGraph}
10-08 09:23:21.900: D/dalvikvm(299): GC_EXPLICIT freed 12K, 55% free 2589K/5703K, external 1625K/2137K, paused 73ms
10-08 09:23:26.950: D/dalvikvm(407): GC_EXPLICIT freed 4K, 55% free 2532K/5511K, external 1625K/2137K, paused 57ms
10-08 09:24:54.097: D/SntpClient(89): request time failed: java.net.SocketException: Address family not supported by protocol
10-08 09:29:54.106: D/SntpClient(89): request time failed: java.net.SocketException: Address family not supported by protocol
10-08 09:34:54.130: D/SntpClient(89): request time failed: java.net.SocketException: Address family not supported by protocol

能否请您帮我找出为什么找不到其他 Activity 。

谢谢

最佳答案

在此声明中将类的名称更改为“LineGraph”而不是“lineGraph”:

public class LineGraph extends Activity{

关于android - java.lang.RuntimeException : Unable to instantiate activity ComponentInfo . ... java.lang.ClassNotFoundException 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12782499/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com