我使用Android Studio创建了一个应用。 它因各种原因连接到互联网 (例如,facebook SDK,Firebase数据库)。
当应用程序在具有构建变体调试模式的真实设备中运行时,它正在连接 但是当应用程序在具有构建变体发布模式的真实设备中运行时,它不会连接到互联网。
这是我的构建gradle和android清单文件
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<application
android:name=".GenarateHashKey"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/app_id" />
<activity
android:name=".StartScreen"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/title_activity_start_screen"
android:theme="@style/FullscreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".QuestionList" />
<activity android:name=".SignInScreen" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity android:name=".ReportThisQuestionActivity" />
<activity android:name=".UpdateQuestionlistActivity" />
</application>
这是我的gradle文件
apply plugin: 'com.android.application'android {
signingConfigs {
KarateRefereeQuiz {
}
}
compileSdkVersion 23
buildToolsVersion "23.0.2"
repositories {
mavenCentral()
}
defaultConfig {
applicationId "com.example.prasad.karaterefereequiz"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile files('libs/commons-io-2.4.jar')
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile files('libs/firebase-client-android-2.5.2.jar')
}
答案 0 :(得分:0)
从我的gradle构建:
signingConfigs {
release {
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
后面是依赖项,然后是:
allprojects {
afterEvaluate { project ->
def propsFile = rootProject.file('keystore.properties')
def configName = 'release'
if (propsFile.exists() && android.signingConfigs.hasProperty(configName)) {
def props = new Properties()
props.load(new FileInputStream(propsFile))
android.signingConfigs[configName].storeFile = file(props['storeFile'])
android.signingConfigs[configName].storePassword = props['storePassword']
android.signingConfigs[configName].keyAlias = props['keyAlias']
android.signingConfigs[configName].keyPassword = props['keyPassword']
}
}
也是依赖关系:
compile fileTree(dir: 'libs', include: ['*.jar'])
答案 1 :(得分:0)
我发现solution.facebook sdk需要realese hashkey for release builds