我正在制作一个使用Firebase的应用, 我之前尝试过许多应用程序,但它们只是无法上网 我不知道为什么,但是我最近的所有应用程序都无法访问互联网, 我已经添加了应该用于互联网访问的权限。 并尝试在标签下添加权限,如我所见,但这没有用。
清单文件:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.co.app">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<provider
android:name=".DatabaseContentProvider"
android:authorities="com.yourpackage.name"
android:exported="false" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LoginActivity" />
<activity android:name=".SignUpActivity" />
<activity
android:name=".nav_drawer"
android:label="@string/title_activity_nav_drawer"
android:theme="@style/AppTheme" />
<activity android:name=".list" />
<activity android:name=".detail"></activity>
</application>
</manifest>
Build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.co.app"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation "com.google.firebase:firebase-core:16.0.4"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-auth:16.0.4'
implementation 'com.google.android.gms:play-services-base:16.0.1'
implementation 'com.google.android.gms:play-services-analytics:16.0.4'
implementation 'com.google.firebase:firebase-database:16.0.3'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
//add libraries
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
compile 'com.parse:parse-android:1.16.3' //update version to the latest one
compile 'com.android.support:design:27.1.1'
compile 'com.android.support:recyclerview-v7:27.1.1'
compile 'com.android.support:cardview-v7:27.1.1'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-database:10.2.0'
compile 'com.firebaseui:firebase-ui-database:1.2.0'
compile 'info.hoang8f:fbutton:1.0.5'
compile 'com.cepheuen.elegant-number-button:lib:1.0.2'
compile 'com.squareup.picasso:picasso:2.5.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
testCompile 'junit:junit:4.12'
// compile fileTree(dir: 'libs',include: ['*.jar'])
//androidTestImplementation(com.android.support.test.espresso:espresso-cor2.2.2',)
//[add the library]
}
apply plugin: 'com.google.gms.google-services'
答案 0 :(得分:0)
对于23rd及以上版本的android API,将以下行添加到
<application
...
android:usesCleartextTraffic="true"
..
</application>