![](/img/trans.png)
[英]Configuring ProGuard for android-eclipse project with multiple jars
[英]How to fix android-eclipse HelloWorld application?
我有一个问题,我不确定该怎么问。 因此,请给我指导,因为我是开发android应用程序的初学者(这是迄今为止最复杂,最繁琐且最令人困惑的事情!)。
我创建了一个新的“ Hello World”项目,不得不做一些其他设置工作(或其他,完全不确定我所做的事情),然后使用枚举器“运行”我的第一个android应用程序。 模拟器启动,应用程序“ Hello World”立即停止,并显示以下消息:
The application HelloWorld (process ...) has stopped unexpectedly. Please try again.
在我的日食窗口中,我看到以下三个警告,但是我不确定它是否与上面的实际问题有关:
Could not locate '/home/alexander/opt/src/android-sdk-linux/extras/android/support/v7/appcompat/bin/android-support-v7-appcompat.jar'. This will not be added to the package.
The type ActionBarActivity is deprecated MainActivity.java /HelloWorld/src/com/example/helloworld line 3 Java Problem
The type ActionBarActivity is deprecated MainActivity.java /HelloWorld/src/com/example/helloworld line 10 Java Problem
这是MainActivity.java的内容:
package com.example.helloworld;
import android.support.v7.app.ActionBarActivity;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
@SuppressLint("NewApi") public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_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;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
我该如何解决这个问题? 我什至如何开始找出问题所在? 还有其他方法可以更简单地创建android应用程序吗? 还是必须真的很复杂,麻烦且令人困惑……?
您似乎没有正确的SDK版本。 因此它无法加载ActionBarActivity
。
另外,还描述了ActionBarActivity
,因此您可能要使用AppCompatActivity
。
参考: https : //developer.android.com/reference/android/support/v7/app/ActionBarActivity.html
我还建议切换到Android Studio,因为它更易于管理SDK。
尝试这个
Add android-support-v7-appcompat.jar to your Buildpath
Right click on your Project --> Properties --> Java Build Path --> Libraries tab --> Add External JAR --> Browse --> add android-support-v7-appcompat.jar --> ok --> Apply --> ok
Clean and build your project and run.
希望这会起作用...
用下面的代码替换您的MainActivity.java
包com.example.helloworld;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
公共类MainActivity扩展了Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.