簡體   English   中英

我的應用無法訪問互聯網-為什么?

[英]My apps can't get internet access - why so?

我正在制作一個使用Firebase的應用程序,我之前嘗試過許多應用程序,但它們只是無法訪問Internet,我不知道為什么,但是我所有的最后一個應用程序都無法訪問Internet,我已經添加了應該用於互聯網訪問。 並嘗試在標簽下添加權限,如我所見,但這沒有用。

清單文件:

<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'

對於android API 23rd及更高版本,將以下行添加到

<application
...
android:usesCleartextTraffic="true"
..
</application>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM