我正在尝试使用Android
构建Gradle
应用,并自动在设备上运行它。我使用Eclipse Kepler。这是我的命令:
~/Documents/Multiverse: $ gradle appStart
我收到此错误:
:appStart
Starting: Intent { cmp=com.alwawee.main/.MainActivity }
Error type 3
Error: Activity class {com.alwawee.main/com.alwawee.main.MainActivity} does not exist.
我无法理解如何解决这个问题。
我的Gradle.build
文件:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.1'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar')
compile files('libs/androidannotations-api-3.0.1.jar')
compile files('libs/commons-lang3-3.1.jar')
compile files('libs/flurryAnalytics_3.4.0.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "19.1"
}
android {
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
androidTest.setRoot('tests')
}
}
/*android {
lintOptions {
abortOnError false
}
}*/
task appStart(type: Exec, dependsOn: ':installDebug') {
// linux
commandLine 'adb', 'shell', 'am', 'start', '-n', 'com.alwawee.main/com.alwawee.main.MainActivity'
// windows
// commandLine 'cmd', '/c', 'adb', 'shell', 'am', 'start', '-n', 'com.alwawee.main/com.alwawee.main.MainActivity'
}
这是我在Eclipse中的src结构:
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.alwawee.multiverse"
android:versionCode="2"
android:versionName="1.0.8" >
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<application android:name="com.alwawee.application.AppApplication"
android:allowBackup="false"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/android:Theme.Holo.Light" >
<activity
android:name="com.alwawee.main.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.alwawee.webView.WebViewActivity"
android:icon="@drawable/ic_launcher"
android:label="@string/web_activity_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="com.example.intentdemo.LAUNCH" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
</intent-filter>
</activity>
<activity
android:name="com.alwawee.entityList.MVEntityListActivity"
android:label=""
android:parentActivityName="com.alwawee.main.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.alwawee.entitylist.EntityListActivity" />
</activity>
</application>
</manifest>
问题可能是我使用自定义Application
。
答案 0 :(得分:1)
您的命令行错误。您的包名称为com.alwawee.multiverse
。变化:
commandLine 'adb', 'shell', 'am', 'start', '-n', 'com.alwawee.main/com.alwawee.main.MainActivity'
为:
commandLine 'adb', 'shell', 'am', 'start', '-n', 'com.alwawee.multiverse/com.alwawee.main.MainActivity'