APK正在设备上安装,但不会自动启动

时间:2015-03-07 10:38:49

标签: android

我正在使用android studio安装一个android应用程序,我需要使用一个使用内置其他库的库。所以我已经为我的项目添加了下一个依赖项。

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'net.koofr:java-koofr:1.2.8'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'org.apache.httpcomponents:httpmime:4.2.3'
    compile 'org.apache.httpcomponents:httpclient:4.3.5'
    compile 'org.restlet.jse:org.restlet.ext.jackson:2.1.2'
}

我正在尝试使用koofr库使用用户名和密码连接到云系统。我在开始这个项目时遇到的一个问题是,我不知道koofr使用其他依赖项来工作。我已经添加了其余的依赖项。

我的app.gradle来自app文件夹:

apply plugin: 'com.android.application'

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'net.koofr:java-koofr:1.2.8'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'org.apache.httpcomponents:httpmime:4.2.3'
    compile 'org.apache.httpcomponents:httpclient:4.3.5'
    compile 'org.restlet.jse:org.restlet.ext.jackson:2.1.2'
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "marianpavel.digimusicstream"
        minSdkVersion 16
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/services/org.restlet.engine.ClientHelper'
    }
}

repositories{
    maven {
        url 'http://maven.restlet.com'
    }
}

您可以注意到依赖关系位于构建渐变的顶部。

我遇到的下一个问题是在我尝试运行应用程序时遇到错误,如:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:packageDebug'.
> Duplicate files copied in APK META-INF/NOTICE
    File 1: C:\Users\marinica\.gradle\caches\modules-2\files-2.1\org.codehaus.jackson\jackson-core-asl\1.9.8\e04e8b2defcbf2e365b75498a36475f2cddc44ba\jackson-core-asl-1.9.8.jar
    File 2: C:\Users\marinica\.gradle\caches\modules-2\files-2.1\org.codehaus.jackson\jackson-core-asl\1.9.8\e04e8b2defcbf2e365b75498a36475f2cddc44ba\jackson-core-asl-1.9.8.jar

所以我修改了gradle文件,添加了所有这些排除:

packagingOptions {
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/services/org.restlet.engine.ClientHelper'
}

另外我在gradle控制台中注意到了一些警告,我试图解决但是我没有找到任何解决方案,一些与我的依赖关系的冲突与来自android studio / android的库中构建。

Configuration on demand is an incubating feature.
WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.3 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.3 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.3 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.3 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72103Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42103Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices6587Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl UP-TO-DATE
:app:processDebugAndroidTestManifest UP-TO-DATE
:app:compileDebugAndroidTestRenderscript UP-TO-DATE
:app:generateDebugAndroidTestBuildConfig UP-TO-DATE
:app:generateDebugAndroidTestAssets UP-TO-DATE
:app:mergeDebugAndroidTestAssets UP-TO-DATE
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources UP-TO-DATE
:app:mergeDebugAndroidTestResources UP-TO-DATE
:app:processDebugAndroidTestResources UP-TO-DATE
:app:generateDebugAndroidTestSources UP-TO-DATE

BUILD SUCCESSFUL

Total time: 2.95 secs

我说的是我遇到的所有这些问题,因为现在当我尝试使用登录屏幕运行我的应用程序时,我可以在设备上安装但它没有自动显示,我在应用管理器中找到了已安装,但我无法在任何可以运行它的地方看到它。这很奇怪,以前从未发生过。如果需要更多信息,我可以提供。

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="marianpavel.digimusicstream" >

    <!-- To auto-complete the email text field in the login form with the user's emails -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.READ_PROFILE" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".LoginActivity"
            android:label="@string/app_name"
            android:windowSoftInputMode="adjustResize|stateVisible" >
        </activity>
        <activity
            android:name=".LoginForm"
            android:label="@string/title_activity_login_form" >
        </activity>
    </application>

</manifest>

谢谢。

2 个答案:

答案 0 :(得分:1)

您没有在清单中提供启动器条目。将启动器intent-filter添加到您的活动中以解决问题。

<activity
        android:name=".LoginActivity"
        android:label="@string/app_name"
        android:windowSoftInputMode="adjustResize|stateVisible" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />

    </intent-filter>
</activity>

答案 1 :(得分:1)

只需将您的清单代码替换为下面的代码即可。

<activity
            android:name="marianpavel.digimusicstream.SplashScreen"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

对于自动启动活动,使其成为启动器活动

相关问题