diff --git a/.travis.yml b/.travis.yml index 165c92043..ce0d59ae8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,8 @@ jdk: android: components: #- tools - #- platform-tools - #- tools + - platform-tools + - tools # The BuildTools version used by your project - build-tools-29.0.2 @@ -37,7 +37,7 @@ before_script: script: - ./gradlew build - ./gradlew :library:createDebugAndroidTestCoverageReport --info --stacktrace - - ./gradlew connectedAndroidTest --info + - ./gradlew connectedAndroidTest --info --stacktrace after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/README.md b/README.md index 6d2579e97..9d9f3a8c9 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ https://github.com/qiniudemo/qiniu-lab-android | 7.0.7 | Android 2.2+ | android-async-http 1.4.8 | ### 注意 -* 推荐使用最新版:7.6.4,7.6.3使用okhttp4.2.2 +* 推荐使用最新版:7.6.4 * 7.4.6是在7.6.4版本上降低okhttp版本,其他功能不变,AndroidNetwork.getMobileDbm()可以获取手机信号强度,需要如下权限(API>=18时生效) ``` @@ -41,12 +41,23 @@ https://github.com/qiniudemo/qiniu-lab-android [happy-dns下载地址](https://repo1.maven.org/maven2/com/qiniu/happy-dns/) ### 通过maven -* 如果在Adroid Studio中使用,添加dependencies `compile 'com.qiniu:qiniu-android-sdk:7.2.+'` 或在项目中添加maven依赖 +* Adroid Studio中添加dependencies 或者 在项目中添加maven依赖 +``` +// 1. 直接导入 +implementation 'com.qiniu:qiniu-android-sdk:7.6.+' + +// 2. 如果要修改okhttp依赖的版本,可采用以下方式(强烈建议使用七牛库依赖的okhttp版本) +implementation ('com.qiniu:qiniu-android-sdk:7.6.+'){ + exclude (group: 'com.squareup.okhttp3', module: 'okhttp') +} +implementation 'com.squareup.okhttp3:okhttp:4.2.2' + +``` * 如果是eclipse, 也可以直接添加依赖来处理。 ## 使用方法 UploadManager 可以创建一次,一直使用。 -7.6.2调用AndroidNetwork.getMobileDbm可以获取网络信号强度 +7.6.2开始调用AndroidNetwork.getMobileDbm可以获取网络信号强度 需要Manifest.permission.ACCESS_FINE_LOCATION和Manifest.permission.ACCESS_COARSE_LOCATION权限 ```java import com.qiniu.android.storage.UploadManager; @@ -80,7 +91,7 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' - compile 'com.qiniu:qiniu-android-sdk:7.2.+' + compile 'com.qiniu:qiniu-android-sdk:7.6.+' } ``` 当然也可以将jar包下载到本地导入到项目中 @@ -607,11 +618,6 @@ import com.qiniu.android.bigdata.pipeline.Pipeline; ... ``` - -## 运行环境 - -Android 最低要求 2.3 - ## 代码贡献 详情参考[代码提交指南](https://github.com/qiniu/android-sdk/blob/master/CONTRIBUTING.md)。 diff --git a/library/build.gradle b/library/build.gradle index f661129c2..a2a7e18d6 100755 --- a/library/build.gradle +++ b/library/build.gradle @@ -57,8 +57,9 @@ dependencies { // for javax.annotation.Nullable use in custom MultipartBody and Headers implements. // implementation 'com.google.code.findbugs:jsr305:3.0.2' implementation fileTree(include: ['*.jar'], dir: 'libs') - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' implementation 'com.google.code.gson:gson:2.8.6' +// androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + testImplementation 'junit:junit:4.13' } task releaseJar(type: Jar, dependsOn: 'build') { diff --git a/library/src/androidTest/java/com/qiniu/android/TestConfig.java b/library/src/androidTest/java/com/qiniu/android/TestConfig.java index d39861b1f..4c84bef95 100644 --- a/library/src/androidTest/java/com/qiniu/android/TestConfig.java +++ b/library/src/androidTest/java/com/qiniu/android/TestConfig.java @@ -10,16 +10,16 @@ public final class TestConfig { // TODO: 2020-05-09 bad token for testPutBytesWithFixedZoneUseBackupDomains //华东上传凭证 public static final String bucket_z0 = "sdk-z0"; - public static final String token_z0 = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW:7MhcqtMD-_D1ADDRkMA1w0okmlE=:eyJzY29wZSI6InNkay16MCIsImRlYWRsaW5lIjoxNTk1MDU4MzEyfQ=="; + public static final String token_z0 = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW:fO65e-s-sRrcNiWkZ3qcrCLM3pM=:eyJzY29wZSI6InNkay16MCIsImRlYWRsaW5lIjoxNTk3MjAyMDYwfQ=="; //华北上传凭证 public static final String bucket_z1 = "sdk-z1"; - public static final String token_z1 = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW:R3WxmBCVotZkVoI0NNZgNDEqcTY=:eyJzY29wZSI6InNkay16MSIsImRlYWRsaW5lIjoxNTk1MDU4MzUwfQ=="; + public static final String token_z1 = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW:KHpcWxGAAut9zJjGaHEqEbjlf-c=:eyJzY29wZSI6InNkay16MSIsImRlYWRsaW5lIjoxNTk3MjAyMDgzfQ=="; //华南上传凭证 public static final String bucket_z2 = "sdk-z2"; - public static final String token_z2 = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW:S9V-5ttyKKfzH59Ncs7wooEOpc4=:eyJzY29wZSI6InNkay16MiIsImRlYWRsaW5lIjoxNTk1MDU4MzY0fQ=="; + public static final String token_z2 = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW:yt7nub2-FOkK2zwodXSgxinpboE=:eyJzY29wZSI6InNkay16MiIsImRlYWRsaW5lIjoxNTk3MjAyMTAwfQ=="; //北美上传凭证 public static final String bucket_na0 = "sdk-na0"; - public static final String token_na0 = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW:hNobj3oBf2OxjafAlH6przLDAOs=:eyJzY29wZSI6InNkay1uYTAiLCJkZWFkbGluZSI6MTU5NTMxNDIyN30="; + public static final String token_na0 = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW:J9AbA4jVl4BtsAFg9XooZaa2Iyk=:eyJzY29wZSI6InNkay1uYTAiLCJkZWFkbGluZSI6MTU5NzIwMjExNX0="; public static final String ak = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW"; diff --git a/library/src/androidTest/java/com/qiniu/android/common/AutoZoneTest.java b/library/src/androidTest/java/com/qiniu/android/common/AutoZoneTest.java index 3a8ce7cf2..10108494d 100644 --- a/library/src/androidTest/java/com/qiniu/android/common/AutoZoneTest.java +++ b/library/src/androidTest/java/com/qiniu/android/common/AutoZoneTest.java @@ -90,16 +90,21 @@ public void onFailure(int reason) { fail(reason + ""); } }); - try { - countDownLatch.await(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - ZoneInfo info = autoZone.zoneInfo(ak, bkt); - ZoneInfo info2 = autoZone.zoneInfo(ak, bkt); - Assert.assertSame(info, info2); + boolean wait = true; + while (wait){ + + wait = false; + + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + wait = true; + } + } + assertTrue(autoZone != null); } }