当我尝试 运行 项目时 signingConfig.storeFile 不存在

signingConfig.storeFile does not exist when I try to run the project

我从 GitHub 下载了一个项目并用 Android Studio 打开了它。所有必需的构建工具和 Android 支持存储库均通过 Android Studio 自动下载。

https://github.com/DrKLO/Telegram

现在我尝试 到 运行 项目 ,我在 Massages 中遇到错误。

Error:A problem was found with the configuration of task ':TMessagesProj:packageDebug'.
> File 'G:\AndroidDev\AndroidStudioProjects\Telegram-master\TMessagesProj\config\release.keystore' specified for property 'signingConfig.storeFile' does not exist.

我在 Stack Exchange 上发现了一些其他话题:

Gradle signing app with packageRelease “specified for property 'signingConfig.storeFile' does not exist”

Android specified for property 'signingConfig.storeFile' does not exist

我按照他们的建议创建了密钥库,但是当我单击 运行 按钮时仍然出现该错误。他们好像和我的不一样。

我还生成了已签名的 APK,当我尝试将其安装到设备上时,程序崩溃并停止,我想这可能是由上述问题引起的。

我确定它应该可以正常工作,因为它是 Telegram Messenger 的官方来源。 https://github.com/DrKLO/Telegram

如果您需要文件 build.gradle:

apply plugin: 'com.android.application'

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.android.support:support-v4:23.1.+'
    compile 'com.google.android.gms:play-services:3.2.+'
    compile 'net.hockeyapp.android:HockeySDK:3.6.+'
    compile 'com.googlecode.mp4parser:isoparser:1.0.+'
}

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'

    useLibrary 'org.apache.http.legacy'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    signingConfigs {
        debug {
            storeFile file("config/release.keystore")
            storePassword RELEASE_STORE_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            keyPassword RELEASE_KEY_PASSWORD
        }

        release {
            storeFile file("config/release.keystore")
            storePassword RELEASE_STORE_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            keyPassword RELEASE_KEY_PASSWORD
        }
    }

    buildTypes {
        debug {
            debuggable true
            jniDebuggable true
            signingConfig signingConfigs.debug
            applicationIdSuffix ".beta"
        }

        release {
            debuggable false
            jniDebuggable false
            signingConfig signingConfigs.release
        }

        foss {
            debuggable false
            jniDebuggable false
            signingConfig signingConfigs.release
        }
    }

    sourceSets.main {
        jniLibs.srcDir 'libs'
        jni.srcDirs = [] //disable automatic ndk-build call
    }

    sourceSets.debug {
        manifest.srcFile 'config/debug/AndroidManifest.xml'
    }

    sourceSets.release {
        manifest.srcFile 'config/release/AndroidManifest.xml'
    }

    sourceSets.foss {
        manifest.srcFile 'config/foss/AndroidManifest.xml'
    }

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 23
        versionCode 695
        versionName "3.3.2"
    }
}

1) 检查storeFile是否存在于路径G:\AndroidDev\AndroidStudioProjects\Telegram-master\TMessagesProj\config\release‌​.keystore

2) 如果不是 - 重命名/将您的密钥库文件移到那里或更改密钥库文件位置的路径。

现在应该可以了。如果您在使用本机代码时遇到构建问题,请尝试此主题 Android Telegram App --> java.lang.UnsatisfiedLinkError: No implementation found for void

您的问题是:Android Studio 正在搜索您告诉它应该存在的密钥文件...但实际上不存在。

您告诉 Android Studio 文件在哪里?

storeFile file("config/release.keystore")

如何创建这个丢失的文件? https://developer.android.com/studio/publish/app-signing.html

如果您已经创建了密钥库,请检查它是否在正确的位置,通常我使用名为 'keystore' 的文件夹而不是 'config',当您浏览搜索它时更直观;)

storeFile rootProject.file("keystore/release.keystore")

要生成密钥库,请转到“构建”>“生成已签名的 APK”并单击“新建密钥库”,现在将生成的文件重命名为 release.keystore 并将其移动到 TMessagesProj/config。

Android Studio 生成 .jks 文件。只需将其从 release.jks 重命名为 release.keystore。然后构建将成功。