Skip to content

- Upgrade project to Android API 33 #425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()

}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.novoda:bintray-release:0.3.4'

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

plugins {
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
}

allprojects {
repositories {
jcenter()
google()
mavenCentral()
maven { url "https://www.jitpack.io" }
}
}
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true

android.useAndroidX=true
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Jun 01 11:58:20 GMT+08:00 2016
#Tue Oct 11 16:36:34 PDT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
zipStoreBase=GRADLE_USER_HOME
70 changes: 50 additions & 20 deletions okhttputils/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'//添加
plugins {
id 'com.android.library'
}

apply from: "$rootProject.projectDir/publishing.gradle"

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
compileSdkVersion 33
buildToolsVersion "33.0.0"

defaultConfig {
minSdkVersion 9
targetSdkVersion 23
minSdkVersion 14
targetSdkVersion 33
versionCode 1
versionName "1.0"
versionName "2.6.3"
}
buildTypes {
release {
Expand All @@ -23,9 +25,11 @@ android {
warning 'InvalidPackage'
}

publishing {
singleVariant('release')
}
}


task clearJar(type: Delete) {
delete 'build/outputs/okhttputils.jar'
}
Expand All @@ -39,20 +43,46 @@ task makeJar(type: Copy) {

makeJar.dependsOn(clearJar, build)

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release

groupId = 'com.zhy'
artifactId = 'okhttputils'
version = "$project.android.defaultConfig.versionName"

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.squareup.okhttp3:okhttp:3.3.1'
pom {
name = 'okhttputils'
description = 'Oh hi, this is a nice description for a project, right?'
url = 'https://github.com/hongyangAndroid/okhttputils'
packaging = 'aar'
licenses {
license {
name = 'Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0'
distribution = 'repo'
}
}
developers {
developer {
id = 'hongyangandroid'
name = 'Hongyang Android'
}
}
scm {
connection = 'scm:hg:https://github.com/hongyangAndroid/okhttputils'
developerConnection = 'scm:hg:https://github.com/hongyangAndroid/okhttputils'
url = 'https://github.com/hongyangAndroid/okhttputils'
}
}
}
}
}
}

//添加
publish {
userOrg = 'hongyangandroid'//bintray.com用户名
groupId = 'com.zhy'//jcenter上的路径
artifactId = 'okhttputils'//项目名称
publishVersion = '2.6.2'//版本号
desc = 'Oh hi, this is a nice description for a project, right?'
website = 'https://github.com/hongyangAndroid/okhttp-utils'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
}

20 changes: 20 additions & 0 deletions publishing.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

publishing {
repositories {
// Enter bintray.com info here
/*maven {
name "sonatype"
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
credentials {
username = project.properties["sonatype_username"]
password = project.properties["sonatype_password"]
}
}*/
}
}

signing {
sign publishing.publications
}
26 changes: 14 additions & 12 deletions sample-okhttp/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
apply plugin: 'com.android.application'
plugins {
id 'com.android.application'
}

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
compileSdkVersion 33
buildToolsVersion "33.0.0"

defaultConfig {
applicationId "com.zhy.sample_okhttp"
minSdkVersion 10
targetSdkVersion 22
minSdkVersion 14
targetSdkVersion 33
versionCode 1
versionName "1.0"
}
Expand All @@ -25,11 +27,11 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile project(':okhttputils')
// compile 'com.zhy:okhttputils:2.6.1'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.2.0'
compile 'com.github.franmontiel:PersistentCookieJar:v0.9.3'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':okhttputils')

implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.2.0'
implementation 'com.github.franmontiel:PersistentCookieJar:v1.0.1'
}
10 changes: 5 additions & 5 deletions sample-okhttp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zhy.sample_okhttp" >

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

<application
android:name="com.zhy.sample_okhttp.MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">

android:theme="@style/AppTheme" >
<activity
android:name="com.zhy.sample_okhttp.MainActivity"
android:label="@string/app_name" >
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.zhy.http.okhttp.https;
package com.zhy.sample_okhttp;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -11,11 +11,9 @@
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
Expand Down Expand Up @@ -64,15 +62,6 @@ public static SSLParams getSslSocketFactory(InputStream[] certificates, InputStr
}
}

private class UnSafeHostnameVerifier implements HostnameVerifier
{
@Override
public boolean verify(String hostname, SSLSession session)
{
return true;
}
}

private static class UnSafeTrustManager implements X509TrustManager
{
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.google.gson.Gson;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.BitmapCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.franmontiel.persistentcookiejar.cache.SetCookieCache;
import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.https.HttpsUtils;
import com.zhy.http.okhttp.log.LoggerInterceptor;

import java.util.concurrent.TimeUnit;
Expand Down
19 changes: 18 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
include ':okhttputils', ':sample-okhttp'
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
/*dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}*/


include ':okhttputils'
include ':sample-okhttp'