添加共享库项目Android

时间:2014-03-22 16:24:39

标签: android shared-libraries android-manifest android-library

我正在努力为我的项目添加一个库。我一直关注其他几个SO以及Android提供的tictactoemain / lib示例,但我仍然无法找到明确的活动类"错误。我在Android Dependencies下显示的库包是com.example.surveymetest。我怀疑问题是我如何调用/定义清单中的活动,但我似乎无法做到正确。我出错的任何想法?

这是我的清单:          

<uses-permission android:name="android.permission.INTERNET" />

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

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<activity
android:name="com.example.surveymedemo.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.surveymetest.SurveyActivity"
android:label="@string/app_name" >
</activity>
<activity android:name="com.example.surveymetest.TakeSurveyActivity" >
</activity>

<provider
android:name="com.example.surveymetest.SurveyMeContentProvider"
android:authorities="io.surveyme.ContentProviders.SurveyMeContentProvider"
android:exported="true" >
</provider>
</application>

</manifest>

致电活动:

package com.example.surveymedemo;

import com.example.surveymetest.StartSurveyActivity;
import com.example.surveymetest.SurveyMe;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent i = new Intent(this, StartSurveyActivity.class);
startActivity(i);
}

@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;
}

}

1 个答案:

答案 0 :(得分:1)

添加:

<activity
    android:name="com.example.surveymetest.StartSurveyActivity"
    android:label="@string/app_name" >
</activity>

到你的清单,你应该是好的。

(您只定义了com.example.surveymetest.SurveyActivity)