【问题标题】:How to call the external library projects in my Android Applications如何在我的 Android 应用程序中调用外部库项目
【发布时间】:2012-07-04 04:46:30
【问题描述】:
import com.example.testQRCode.*;  //<--external project 

public class MainActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // create a new intent based on your library activity
        Intent myIntent = new Intent(this, QRCode.class); // QRCode is a class from the external projects
        startActivityForResult(myIntent, 0);  
    }

异常显示系统无法实例化activity。

请帮帮我。

【问题讨论】:

  • 在 google 上搜索如何在 eclipse 中导入外部项目

标签: java android android-intent android-activity android-library


【解决方案1】:

如果您想在 Eclipse 中包含一个作为 Android 库项目的库,您可以简单地通过添加它

Project Properties-&gt;Android

在此屏幕中,您将看到“项目构建目标”和“库”两个部分。在“库”部分,您可以添加对其他项目的引用。

如果你想包含一个外部 jar 文件,你可以通过

Project Properties-&gt;Java Build Path-&gt;Libraries tab

在这里,有一个“添加外部罐子...”按钮,您可以在其中添加您需要的罐子。

【讨论】:

  • 正如其他人所提到的,您能否编辑问题并发布完整的异常日志。发布 AndroidManifest.xml 也可能有用
【解决方案2】:

您还必须在主项目的 AndroidManifest.xml 文件中声明 QRCode.class 的 Activity 类。

【讨论】:

  • 那么请贴出异常的堆栈跟踪。
猜你喜欢
  • 2014-12-28
  • 2011-11-10
  • 1970-01-01
  • 2019-11-16
  • 1970-01-01
  • 1970-01-01
  • 2012-09-13
  • 2013-05-12
相关资源
最近更新 更多