Android上的FileDownloader没有显示任何错误,但下载未开始 [英] FileDownloader at the android it is showing no errors but the download does not start

查看:774
本文介绍了Android上的FileDownloader没有显示任何错误,但下载未开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试下载一个简单的 .pdf 文件,但我没有尝试任何日志,但没有错误。我尝试调试,但直到昨天它仍然像魅力一样工作,但直到今天仍然如此,我在代码的这一部分没有做任何更改。
我是基于SO上的这个问题和答案的。





输出





AndroidManifest.xml

 <?xml version = 1.0 encoding = utf-8?> 
<清单xmlns:android = http://schemas.android.com/apk/res/android
package = com.zackdawood>

<使用权限android:name = android.permission.INTERNET />


< uses-permission android:name = android.permission.WRITE_EXTERNAL_STORAGE>< / uses-permission>
< uses-permission android:name = android.permission.READ_EXTERNAL_STORAGE>< / uses-permission>

<应用程序
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
android:networkSecurityConfig = @ xml / network_security_config>
< provider
android:name =。GenericFileProvider
android:authorities = $ {applicationId} .fileprovider
android:exported = false
android:grantUriPermissions = true>
<元数据
android:name = android.support.FILE_PROVIDER_PATHS
android:resource = @ xml / external_files />
< / provider>
< activity android:name =。MainActivity>
< intent-filter>
< action android:name = android.intent.action.MAIN />

<类别android:name = android.intent.category.LAUNCHER />
< / intent-filter>
< / activity>
< / application>

< / manifest>

GenericFileProvider.java

  package com.zackdawood; 

import android.support.v4.content.FileProvider;

公共类GenericFileProvider扩展了FileProvider {
}

FileDownloader。 java

  package com.zackdawood; 

import android.util.Log;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

公共类FileDownloader {

private static final String TAG = FileDownloader;

private static final int MEGABYTE = 1024 * 1024;

public static void downloadFile(String fileUrl,File directory){
try {
Log.v(TAG, downloadFile()invoked);
Log.v(TAG, downloadFile()fileUrl + fileUrl);
Log.v(TAG, downloadFile()directory +目录);

URL url =新URL(fileUrl);
HttpURLConnection urlConnection =(HttpURLConnection)url.openConnection();
urlConnection.connect();

InputStream inputStream = urlConnection.getInputStream();
FileOutputStream fileOutputStream =新的FileOutputStream(目录);
int totalSize = urlConnection.getContentLength();

byte [] buffer = new byte [MEGABYTE];
int bufferLength = 0;
while(((bufferLength = inputStream.read(buffer))> 0){
fileOutputStream.write(buffer,0,bufferLength);
}
fileOutputStream.close();
Log.v(TAG, downloadFile()已完成);

} catch(FileNotFoundException e){
e.printStackTrace();
Log.e(TAG, downloadFile()error + e.getMessage());
Log.e(TAG, downloadFile()error + e.getStackTrace());
} catch(MalformedURLException e){
e.printStackTrace();
Log.e(TAG, downloadFile()error + e.getMessage());
Log.e(TAG, downloadFile()error + e.getStackTrace());
} catch(IOException e){
e.printStackTrace();
Log.e(TAG, downloadFile()error + e.getMessage());
Log.e(TAG, downloadFile()error + e.getStackTrace());
}
}
}

MainActivity.java

  package com.zackdawood; 

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import java.io.File;
import java.io.IOException;

公共类MainActivity扩展了AppCompatActivity {

private static final String TAG = MainActivity;
private static final String [] PERMISSIONS = {android.Manifest.permission.READ_EXTERNAL_STORAGE,android.Manifest.permission.WRITE_EXTERNAL_STORAGE};


private static boolean hasPermissions(Context context,String ... Permissions){
if(Build.VERSION.SDK_INT> = Build.VERSION_CODES.M& = context!= null&&权限!= null){
for(字符串权限:权限){
if(ActivityCompat.checkSelfPermission(context,Permission)!= PackageManager.PERMISSION_GRANTED){
返回false;
}
}
}
返回true;
}

@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.v(TAG, onCreate()方法被调用);

ActivityCompat.requestPermissions(MainActivity.this,PERMISSIONS,112);

}

公共无效请求(视图){

ActivityCompat.requestPermissions(MainActivity.this,PERMISSIONS,112);

}

public void view(View view){
Log.v(TAG, view()方法被调用);

if(!hasPermissions(MainActivity.this,PERMISSIONS)){

Log.v(TAG, download()方法没有权限);

Toast t = Toast.makeText(getApplicationContext(),您没有读取权限!,Toast.LENGTH_LONG);
t.show();

}否则{
文件d = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); //-> filename = maven.pdf
File pdfFile = new File(d, maven.pdf);

Log.v(TAG, view()方法pdfFile + pdfFile.getAbsolutePath());

Uri路径= FileProvider.getUriForFile(this,BuildConfig.APPLICATION_ID + .fileprovider,pdfFile);


Log.v(TAG, view()方法路径 +路径);

Intent pdfIntent =新的Intent(Intent.ACTION_VIEW);
pdfIntent.setDataAndType(path, application / pdf);
pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
pdfIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

试试{
startActivity(pdfIntent);
} catch(ActivityNotFoundException e){
Toast.makeText(MainActivity.this,没有可用的应用程序来查看PDF,Toast.LENGTH_SHORT).show();
}
}
Log.v(TAG, view()方法已完成);

}

public void download(View view){
Log.v(TAG, download()方法调用);

if(!hasPermissions(MainActivity.this,PERMISSIONS)){

Log.v(TAG, download()方法没有权限);

Toast t = Toast.makeText(getApplicationContext(),您没有写权限!,Toast.LENGTH_LONG);
t.show();

} else {
Log.v(TAG, download()方法具有权限);

//新的DownloadFile()。execute( http://maven.apache.org/maven-1.x/maven.pdf, maven.pdf);
新的DownloadFile()。execute( http://www.axmag.com/download/pdfurl-guide.pdf, maven.pdf);

}

Log.v(TAG, download()方法已完成);

}

私有类DownloadFile扩展了AsyncTask< String,Void,Void> {

@Override
受保护的Void doInBackground(字符串...字符串){
Log.v(TAG, doInBackground()方法被调用);

字符串fileUrl =字符串[0]; //-> http://maven.apache.org/maven-1.x/maven.pdf
字符串fileName =字符串[1]; //-> maven.pdf
字符串extStorageDirectory = Environment.getExternalStorageDirectory()。toString();
文件文件夹= Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);

File pdfFile = new File(folder,fileName);
Log.v(TAG, doInBackground()调用的pdfFile + pdfFile.getAbsolutePath());
Log.v(TAG, doInBackground()调用的pdfFile + pdfFile.getAbsoluteFile());

试试{
pdfFile.createNewFile();
Log.v(TAG,创建了doInBackground()文件 + pdfFile);

} catch(IOException e){
e.printStackTrace();
Log.e(TAG, doInBackground()错误 + e.getMessage());
Log.e(TAG, doInBackground()错误 + e.getStackTrace());


}
FileDownloader.downloadFile(fileUrl,pdfFile);
Log.v(TAG, doInBackground()文件下载完成);

返回null;
}
}
}

strings.xml

 < resources> 
< string name = app_name> DemoInternalDownload< / string>
< string name = action_settings>设置< / string>
< string name = file_view>文件视图< / string>
< string name = file_download>文件下载< / string>
< string name = file_request>再次请求访问权限< / string>

< / resources>

external_files.xml

 <?xml version = 1.0 encoding = utf-8?> 
< paths xmlns:android = http://schemas.android.com/apk/res/android>
< external-path name = external_files path =。 />
< / paths>

network_security_config.xml

 <?xml version = 1.0 encoding = utf-8?> 
< network-security-config>
< domain-config cleartextTrafficPermitted = true>
< domain includeSubdomains = true> maven.apache.org< / domain>
< domain includeSubdomains = true> www.axmag.com< / domain>
< / domain-config>
< / network-security-config>

activity_main.xml

 <?xml version = 1.0 encoding = utf-8?> 
< android.support.design.widget.CoordinatorLayout xmlns:android = http://schemas.android.com/apk/res/android
xmlns:app = http:// schemas .android.com / apk / res-auto
xmlns:tools = http://schemas.android.com/tools
android:layout_width = match_parent
android:layout_height = match_parent
tools:context =。MainActivity>

< LinearLayout
android:layout_width = match_parent
android:layout_height = match_parent
android:orientation = vertical>

<按钮
android:id = @ + id / button3
android:layout_width = match_parent
android:layout_height = wrap_content
android:layout_marginTop = 200px
android:onClick = download
android:text = @ string / file_download />


< Button
android:id = @ + id / button4
android:layout_width = match_parent
android:layout_height = wrap_content
android:layout_marginTop = 200px
android:onClick = view
android:text = @ string / file_view />

<按钮
android:id = @ + id / button5
android:layout_width = match_parent
android:layout_height = wrap_content
android:layout_marginTop = 200px
android:onClick = request
android:text = @ string / file_request />
< / LinearLayout>


< /android.support.design.widget.CoordinatorLayout>

build.gradle

  Apply插件:'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId com.zackdawood
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName 1.0
testInstrumentationRunner android.support.test.runner.AndroidJUnitRunner
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
}
}
}

依赖项{
实现fileTree(dir:'libs',包括:['* .jar'])
实现'com.android.support:appcompat- v7:28.0.0'
实现'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation'com.android.support.test.espresso:espresso-core:3.0.2'
}


I am trying to download a simple .pdf file I have tried logs but no errors and nothing. I tried to debug but the same till yesterday it worked like charm but not today, I didn't change nothing at this part of the code. I am based at this question and answer at SO.

https://stackoverflow.com/a/24748227/9560126

Below is the code.

Sometimes at the LogCat it shows me only like message something like this.

com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:251) FileDownloader.downloadFile

at this line of code.

inputStream = urlConnection.getInputStream();

The code of Url connection.

urlConnection.getResponseCode()

It is returning 405

MainActivity.java

String newEntry = "http://www.axmag.com/download/pdfurl-guide.pdf";
new DownloadFile().execute(newEntry, "maven.pdf");

  private static class DownloadFile extends AsyncTask<String, Void, Void>{

    @Override
    protected Void doInBackground(String... strings) {
        String fileUrl = strings[0];   // -> http://maven.apache.org/maven-1.x/maven.pdf
        String fileName = strings[1];  // -> maven.pdf
        String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
        File folder = new File(extStorageDirectory, "testthreepdf");
        folder.mkdir();

        File pdfFile = new File(folder, fileName);

        try{
            pdfFile.createNewFile();
        }catch (IOException e){
            e.printStackTrace();
        }
        FileDownloader.downloadFile(fileUrl, pdfFile);
        return null;
    }
}

FileDownloader.java

public class FileDownloader {
private static final int  MEGABYTE = 1024 * 1024;

public static void downloadFile(String fileUrl, File directory){
    try {

        URL url = new URL(fileUrl);
        HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
        urlConnection.setRequestMethod("GET");
        urlConnection.setDoOutput(true);
        urlConnection.connect();

        InputStream inputStream;
        inputStream = urlConnection.getInputStream();
        FileOutputStream fileOutputStream = new FileOutputStream(directory);
        int totalSize = urlConnection.getContentLength();

        byte[] buffer = new byte[MEGABYTE];
        int bufferLength = 0;
        while((bufferLength = inputStream.read(buffer))>0 ){
            fileOutputStream.write(buffer, 0, bufferLength);
        }
        fileOutputStream.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
 }
}

AndroidManifest.XML

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />

解决方案

The solution is as below, this should fix your problem. There are changes related to API 28 Android Permissions which made your old code obsolete

Access Screen

Output

Code Snapshot

AndroidManifest.xml

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

    <uses-permission android:name="android.permission.INTERNET" />


    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>

    <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"
        android:networkSecurityConfig="@xml/network_security_config">
        <provider
            android:name=".GenericFileProvider"
            android:authorities="${applicationId}.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/external_files"/>
        </provider>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

GenericFileProvider.java

package com.zackdawood;

import android.support.v4.content.FileProvider;

public class GenericFileProvider extends FileProvider {
}

FileDownloader.java

package com.zackdawood;

import android.util.Log;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public class FileDownloader {

    private static final String TAG = "FileDownloader";

    private static final int MEGABYTE = 1024 * 1024;

    public static void downloadFile(String fileUrl, File directory) {
        try {
            Log.v(TAG, "downloadFile() invoked ");
            Log.v(TAG, "downloadFile() fileUrl " + fileUrl);
            Log.v(TAG, "downloadFile() directory " + directory);

            URL url = new URL(fileUrl);
            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
            urlConnection.connect();

            InputStream inputStream = urlConnection.getInputStream();
            FileOutputStream fileOutputStream = new FileOutputStream(directory);
            int totalSize = urlConnection.getContentLength();

            byte[] buffer = new byte[MEGABYTE];
            int bufferLength = 0;
            while ((bufferLength = inputStream.read(buffer)) > 0) {
                fileOutputStream.write(buffer, 0, bufferLength);
            }
            fileOutputStream.close();
            Log.v(TAG, "downloadFile() completed ");

        } catch (FileNotFoundException e) {
            e.printStackTrace();
            Log.e(TAG, "downloadFile() error" + e.getMessage());
            Log.e(TAG, "downloadFile() error" + e.getStackTrace());
        } catch (MalformedURLException e) {
            e.printStackTrace();
            Log.e(TAG, "downloadFile() error" + e.getMessage());
            Log.e(TAG, "downloadFile() error" + e.getStackTrace());
        } catch (IOException e) {
            e.printStackTrace();
            Log.e(TAG, "downloadFile() error" + e.getMessage());
            Log.e(TAG, "downloadFile() error" + e.getStackTrace());
        }
    }
}

MainActivity.java

package com.zackdawood;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import java.io.File;
import java.io.IOException;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";
    private static final String[] PERMISSIONS = {android.Manifest.permission.READ_EXTERNAL_STORAGE, android.Manifest.permission.WRITE_EXTERNAL_STORAGE};


    private static boolean hasPermissions(Context context, String... permissions) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && context != null && permissions != null) {
            for (String permission : permissions) {
                if (ActivityCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
                    return false;
                }
            }
        }
        return true;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.v(TAG, "onCreate() Method invoked ");

        ActivityCompat.requestPermissions(MainActivity.this, PERMISSIONS, 112);

    }

    public void request(View view) {

        ActivityCompat.requestPermissions(MainActivity.this, PERMISSIONS, 112);

    }

    public void view(View view) {
        Log.v(TAG, "view() Method invoked ");

        if (!hasPermissions(MainActivity.this, PERMISSIONS)) {

            Log.v(TAG, "download() Method DON'T HAVE PERMISSIONS ");

            Toast t = Toast.makeText(getApplicationContext(), "You don't have read access !", Toast.LENGTH_LONG);
            t.show();

        } else {
            File d = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);  // -> filename = maven.pdf
            File pdfFile = new File(d, "maven.pdf");

            Log.v(TAG, "view() Method pdfFile " + pdfFile.getAbsolutePath());

            Uri path = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".fileprovider", pdfFile);


            Log.v(TAG, "view() Method path " + path);

            Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
            pdfIntent.setDataAndType(path, "application/pdf");
            pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            pdfIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

            try {
                startActivity(pdfIntent);
            } catch (ActivityNotFoundException e) {
                Toast.makeText(MainActivity.this, "No Application available to view PDF", Toast.LENGTH_SHORT).show();
            }
        }
        Log.v(TAG, "view() Method completed ");

    }

    public void download(View view) {
        Log.v(TAG, "download() Method invoked ");

        if (!hasPermissions(MainActivity.this, PERMISSIONS)) {

            Log.v(TAG, "download() Method DON'T HAVE PERMISSIONS ");

            Toast t = Toast.makeText(getApplicationContext(), "You don't have write access !", Toast.LENGTH_LONG);
            t.show();

        } else {
            Log.v(TAG, "download() Method HAVE PERMISSIONS ");

            //new DownloadFile().execute("http://maven.apache.org/maven-1.x/maven.pdf", "maven.pdf");
            new DownloadFile().execute("http://www.axmag.com/download/pdfurl-guide.pdf", "maven.pdf");

        }

        Log.v(TAG, "download() Method completed ");

    }

    private class DownloadFile extends AsyncTask<String, Void, Void> {

        @Override
        protected Void doInBackground(String... strings) {
            Log.v(TAG, "doInBackground() Method invoked ");

            String fileUrl = strings[0];   // -> http://maven.apache.org/maven-1.x/maven.pdf
            String fileName = strings[1];  // -> maven.pdf
            String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
            File folder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);

            File pdfFile = new File(folder, fileName);
            Log.v(TAG, "doInBackground() pdfFile invoked " + pdfFile.getAbsolutePath());
            Log.v(TAG, "doInBackground() pdfFile invoked " + pdfFile.getAbsoluteFile());

            try {
                pdfFile.createNewFile();
                Log.v(TAG, "doInBackground() file created" + pdfFile);

            } catch (IOException e) {
                e.printStackTrace();
                Log.e(TAG, "doInBackground() error" + e.getMessage());
                Log.e(TAG, "doInBackground() error" + e.getStackTrace());


            }
            FileDownloader.downloadFile(fileUrl, pdfFile);
            Log.v(TAG, "doInBackground() file download completed");

            return null;
        }
    }
}

strings.xml

<resources>
    <string name="app_name">DemoInternalDownload</string>
    <string name="action_settings">Settings</string>
    <string name="file_view">File View</string>
    <string name="file_download">File Download</string>
    <string name="file_request">Request Access Again</string>

</resources>

external_files.xml

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="external_files" path="."/>
</paths>

network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">maven.apache.org</domain>
        <domain includeSubdomains="true">www.axmag.com</domain>
    </domain-config>
</network-security-config>

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <Button
            android:id="@+id/button3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="200px"
            android:onClick="download"
            android:text="@string/file_download" />


        <Button
            android:id="@+id/button4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="200px"
            android:onClick="view"
            android:text="@string/file_view" />

        <Button
            android:id="@+id/button5"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="200px"
            android:onClick="request"
            android:text="@string/file_request" />
    </LinearLayout>


</android.support.design.widget.CoordinatorLayout>

build.gradle

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.zackdawood"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

这篇关于Android上的FileDownloader没有显示任何错误,但下载未开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆