生成离子Cordova构建android时,我的OkConnectionFactory.java文件中出现此错误

时间:2019-10-03 09:24:45

标签: android ionic3 build.gradle

This is my Error message

这是我的Build.gradle文件,正在使用android gradle 3.5.0。我已为该错误分配了权限,但没有任何帮助。

 apply plugin: 'com.android.application'

buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }

    }


    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
    }
}

// Allow plugins to declare Maven dependencies via build-extras.gradle.
allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }

    }
}



/*task wrapper(type: Wrapper) {
    gradleVersion = '5.6.2'
}*/

// Configuration properties. Set these via environment variables, build-extras.gradle, or gradle.properties.
// Refer to: http://www.gradle.org/docs/current/userguide/tutorial_this_and_that.html
ext {
    apply from: 'CordovaLib/cordova.gradle'
// The following are only a few examples of the types of properties you can define.
    compileSdkVersion = 28
    // You can also create properties to specify versions for dependencies.
    // Having consistent versions between modules can avoid conflicts with behavior.
    supportLibVersion = "28.0.0"
    // The value for android.compileSdkVersion.
    if (!project.hasProperty('cdvCompileSdkVersion')) {
        cdvCompileSdkVersion = null;
    }
    // The value for android.buildToolsVersion.
    if (!project.hasProperty('cdvBuildToolsVersion')) {
        cdvBuildToolsVersion = null;
    }
    // Sets the versionCode to the given value.
    if (!project.hasProperty('cdvVersionCode')) {
        cdvVersionCode = null
    }
    // Sets the minSdkVersion to the given value.
    if (!project.hasProperty('cdvMinSdkVersion')) {
        cdvMinSdkVersion = null
    }
    // Whether to build architecture-specific APKs.
    if (!project.hasProperty('cdvBuildMultipleApks')) {
        cdvBuildMultipleApks = null
    }
    // .properties files to use for release signing.
    if (!project.hasProperty('cdvReleaseSigningPropertiesFile')) {
        cdvReleaseSigningPropertiesFile = null
    }
    // .properties files to use for debug signing.
    if (!project.hasProperty('cdvDebugSigningPropertiesFile')) {
        cdvDebugSigningPropertiesFile = null
    }
    // Set by build.js script.
    if (!project.hasProperty('cdvBuildArch')) {
        cdvBuildArch = null
    }

    // Plugin gradle extensions can append to this to have code run at the end.
    cdvPluginPostBuildExtras = []
}

// PLUGIN GRADLE EXTENSIONS START
apply from: "cordova-plugin-code-push/myApp-build-extras.gradle"
apply from: "cordova-android-support-gradle-release/myApp-cordova-android-support-gradle-release.gradle"
// PLUGIN GRADLE EXTENSIONS END

def hasBuildExtras = file('build-extras.gradle').exists()
if (hasBuildExtras) {
    apply from: 'build-extras.gradle'
}

// Set property defaults after extension .gradle files.
if (ext.cdvCompileSdkVersion == null) {
    ext.cdvCompileSdkVersion = privateHelpers.getProjectTarget()
}
if (ext.cdvBuildToolsVersion == null) {
    ext.cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
}
if (ext.cdvDebugSigningPropertiesFile == null && file('debug-signing.properties').exists()) {
    ext.cdvDebugSigningPropertiesFile = 'debug-signing.properties'
}
if (ext.cdvReleaseSigningPropertiesFile == null && file('release-signing.properties').exists()) {
    ext.cdvReleaseSigningPropertiesFile = 'release-signing.properties'
}

// Cast to appropriate types.
ext.cdvBuildMultipleApks = cdvBuildMultipleApks == null ? false : cdvBuildMultipleApks.toBoolean();
ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? null : Integer.parseInt('' + cdvMinSdkVersion)
ext.cdvVersionCode = cdvVersionCode == null ? null : Integer.parseInt('' + cdvVersionCode)

def computeBuildTargetName(debugBuild) {
    def ret = 'assemble'
    if (cdvBuildMultipleApks && cdvBuildArch) {
        def arch = cdvBuildArch == 'arm' ? 'armv7' : cdvBuildArch
        ret += '' + arch.toUpperCase().charAt(0) + arch.substring(1);
    }
    return ret + (debugBuild ? 'Debug' : 'Release')
}

// Make cdvBuild a task that depends on the debug/arch-sepecific task.
task cdvBuildDebug
cdvBuildDebug.dependsOn {
    return computeBuildTargetName(true)
}

task cdvBuildRelease
cdvBuildRelease.dependsOn {
    return computeBuildTargetName(false)
}

task cdvPrintProps doLast {
    println('cdvCompileSdkVersion=' + cdvCompileSdkVersion)
    println('cdvBuildToolsVersion=' + cdvBuildToolsVersion)
    println('cdvVersionCode=' + cdvVersionCode)
    println('cdvMinSdkVersion=' + cdvMinSdkVersion)
    println('cdvBuildMultipleApks=' + cdvBuildMultipleApks)
    println('cdvReleaseSigningPropertiesFile=' + cdvReleaseSigningPropertiesFile)
    println('cdvDebugSigningPropertiesFile=' + cdvDebugSigningPropertiesFile)
    println('cdvBuildArch=' + cdvBuildArch)
    println('computedVersionCode=' + android.defaultConfig.versionCode)
    android.productFlavors.each { flavor ->
        println('computed' + flavor.name.capitalize() + 'VersionCode=' + flavor.versionCode)
    }
}

android {
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
        }
    }

    defaultConfig {
        versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))
        applicationId privateHelpers.extractStringFromManifest("package")
        minSdkVersion 16

        if (cdvMinSdkVersion != null) {
            minSdkVersion cdvMinSdkVersion
        }
    }

    lintOptions {
      abortOnError false;
    }

    compileSdkVersion 27
    buildToolsVersion '28.0.3'

    if (Boolean.valueOf(cdvBuildMultipleApks)) {
        productFlavors {
            armv7 {
                versionCode defaultConfig.versionCode*10 + 2
                ndk {
                    abiFilters "armeabi-v7a", ""
                }
            }
            x86 {
                versionCode defaultConfig.versionCode*10 + 4
                ndk {
                    abiFilters "x86", ""
                }
            }
            all {
                ndk {
                    abiFilters "all", ""
                }
            }
        }
    }
 signingConfigs {
        //Your configuration here
        Production {
                // These must be set or Gradle will complain (even if they are overridden).
                keyAlias = ""
                keyPassword = "__unset" // And these must be set to non-empty in order to have the signing step added to the task graph.
                storeFile = null
                storePassword = "__unset"
            }
        release {
                // These must be set or Gradle will complain (even if they are overridden).
                keyAlias = ""
                keyPassword = "__unset" // And these must be set to non-empty in order to have the signing step added to the task graph.
                storeFile = null
                storePassword = "__unset"
            }

       }
    buildTypes {

     release {
         lintOptions {
             checkReleaseBuilds false
             // Or, if you prefer, you can continue to check for errors in release builds,
             // but continue the build even when errors are found:
             abortOnError false
         }
         debuggable true
         minifyEnabled true
         proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         signingConfig signingConfigs.Production
         buildConfigField "String", "SERVER_URL", '"http://192.131.543"'    
      }

    debug {
        debuggable true
        buildConfigField "String", "SERVER_URL", '"http://192.131.543"'

    } 
}
    /*

    ELSE NOTHING! DON'T MESS WITH THE VERSION CODE IF YOU DON'T HAVE TO!

    else if (!cdvVersionCode) {
      def minSdkVersion = cdvMinSdkVersion ?: privateHelpers.extractIntFromManifest("minSdkVersion")
      // Vary versionCode by the two most common API levels:
      // 14 is ICS, which is the lowest API level for many apps.
      // 20 is Lollipop, which is the lowest API level for the updatable system webview.
      if (minSdkVersion >= 20) {
        defaultConfig.versionCode += 9
      } else if (minSdkVersion >= 14) {
        defaultConfig.versionCode += 8
      }
    }
    */

   /* compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_6
        targetCompatibility JavaVersion.VERSION_1_6
    } */

    if (cdvReleaseSigningPropertiesFile) {
        signingConfigs {
            release {
                // These must be set or Gradle will complain (even if they are overridden).
                keyAlias = ""
                keyPassword = "__unset" // And these must be set to non-empty in order to have the signing step added to the task graph.
                storeFile = null
                storePassword = "__unset"
            }

            Production {
                // These must be set or Gradle will complain (even if they are overridden).
                keyAlias = ""
                keyPassword = "__unset" // And these must be set to non-empty in order to have the signing step added to the task graph.
                storeFile = null
                storePassword = "__unset"
            }

        }
        buildTypes {
            release {
                signingConfig signingConfigs.release
            }

            Production {
                signingConfig signingConfigs.Production
            }

        }
        addSigningProps(cdvReleaseSigningPropertiesFile, signingConfigs.release)
    }
    if (cdvDebugSigningPropertiesFile) {
        addSigningProps(cdvDebugSigningPropertiesFile, signingConfigs.debug)
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: '*.jar')
   // implementation project(':CordovaLib')
    // SUB-PROJECT DEPENDENCIES START
    compile project('CordovaLib')
    compile "com.squareup.okhttp3:okhttp-urlconnection:4.1.1"
    compile "com.android.support:support-v4:27.1.0"
    // SUB-PROJECT DEPENDENCIES END
}

def promptForReleaseKeyPassword() {
    if (!cdvReleaseSigningPropertiesFile) {
        return;
    }
    if ('__unset'.equals(android.signingConfigs.release.storePassword)) {
        android.signingConfigs.release.storePassword = privateHelpers.promptForPassword('Enter key store password: ')
    }
    if ('__unset'.equals(android.signingConfigs.release.keyPassword)) {
        android.signingConfigs.release.keyPassword = privateHelpers.promptForPassword('Enter key password: ');
    }
}

gradle.taskGraph.whenReady { taskGraph ->
    taskGraph.getAllTasks().each() { task ->
        if (task.name == 'validateReleaseSigning' || task.name == 'validateSigningRelease') {
            promptForReleaseKeyPassword()
        }
    }
}

def addSigningProps(propsFilePath, signingConfig) {
    def propsFile = file(propsFilePath)
    def props = new Properties()
    propsFile.withReader { reader ->
        props.load(reader)
    }

    def storeFile = new File(props.get('key.store') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'storeFile'))
    if (!storeFile.isAbsolute()) {
        storeFile = RelativePath.parse(true, storeFile.toString()).getFile(propsFile.getParentFile())
    }
    if (!storeFile.exists()) {
        throw new FileNotFoundException('Keystore file does not exist: ' + storeFile.getAbsolutePath())
    }
    signingConfig.keyAlias = props.get('key.alias') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'keyAlias')
    signingConfig.keyPassword = props.get('keyPassword', props.get('key.alias.password', signingConfig.keyPassword))
    signingConfig.storeFile = storeFile
    signingConfig.storePassword = props.get('storePassword', props.get('key.store.password', signingConfig.storePassword))
    def storeType = props.get('storeType', props.get('key.store.type', ''))
    if (!storeType) {
        def filename = storeFile.getName().toLowerCase();
        if (filename.endsWith('.p12') || filename.endsWith('.pfx')) {
            storeType = 'pkcs12'
        } else {
            storeType = signingConfig.storeType // "jks"
        }
    }
    signingConfig.storeType = storeType
}

for (def func : cdvPluginPostBuildExtras) {
    func()
}

// This can be defined within build-extras.gradle as:
//     ext.postBuildExtras = { ... code here ... }
if (hasProperty('postBuildExtras')) {
    postBuildExtras()
}

这是我的CordovaLib Build.gradle文件。任何帮助将不胜感激。

   ext {
    apply from: 'cordova.gradle'
    cdvCompileSdkVersion = privateHelpers.getProjectTarget()
    cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
}

buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }

   dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
    }
}

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

group = 'org.apache.cordova'
version = '6.3.0'

android {
    compileSdkVersion cdvCompileSdkVersion
    buildToolsVersion cdvBuildToolsVersion
    publishNonDefault true

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_6
        targetCompatibility JavaVersion.VERSION_1_6
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
    }
    defaultConfig {
        minSdkVersion 14
    }
}

install {
    repositories.mavenInstaller {
        pom {
            project {
                packaging 'aar'
                name 'Cordova'
                url 'https://cordova.apache.org'
                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id 'stevengill'
                        name 'Steve Gill'
                    }
                }
                scm {
                    connection 'https://git-wip-us.apache.org/repos/asf?p=cordova-android.git'
                    developerConnection 'https://git-wip-us.apache.org/repos/asf?p=cordova-android.git'
                    url 'https://git-wip-us.apache.org/repos/asf?p=cordova-android'

                }
            }
        }
    }
}

task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

artifacts {
    archives sourcesJar
}

bintray {
    user = System.getenv('BINTRAY_USER')
    key = System.getenv('BINTRAY_KEY')
    configurations = ['archives']
    pkg {
        repo = 'maven'
        name = 'cordova-android'
        userOrg = 'cordova'
        licenses = ['Apache-2.0']
        vcsUrl = 'https://git-wip-us.apache.org/repos/asf?p=cordova-android.git'
        websiteUrl = 'https://cordova.apache.org'
        issueTrackerUrl = 'https://issues.apache.org/jira/browse/CB'
        publicDownloadNumbers = true
        licenses = ['Apache-2.0']
        labels = ['android', 'cordova', 'phonegap']
        version {
            name = '6.3.0'
            released  = new Date()
            vcsTag = '6.3.0'
        }
    }
}

这是我的发布网址

  

distributionUrl = https://services.gradle.org/distributions/gradle-5.4.1-all.zip

这是我的okConnectionFactory.java文件

    package com.github.kevinsawicki.http;
import okhttp3.OkUrlFactory;
import okhttp3.OkHttpClient;
import java.net.URL;
import java.net.HttpURLConnection;
import java.net.URLStreamHandler;
import java.net.Proxy;


public class OkConnectionFactory implements HttpRequest.ConnectionFactory {

    protected OkHttpClient okHttpClient = new OkHttpClient();

    public HttpURLConnection create(URL url) {
        OkUrlFactory okUrlFactory = new OkUrlFactory(okHttpClient);
        return (HttpURLConnection) okUrlFactory.open(url);
    }

    public HttpURLConnection create(URL url, Proxy proxy) {
        OkHttpClient okHttpClientWithProxy = okHttpClient.newBuilder().proxy(proxy).build();
        OkUrlFactory okUrlFactory = new OkUrlFactory(okHttpClientWithProxy);
        return (HttpURLConnection) okUrlFactory.open(url);
    }
}

这是我的插件列表

 {
  "homepage": "",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@agm/core": "1.0.0-beta.3",
    "@angular/common": "4.0.0",
    "@angular/compiler": "4.0.0",
    "@angular/compiler-cli": "4.0.0",
    "@angular/core": "4.0.0",
    "@angular/forms": "4.0.0",
    "@angular/http": "4.0.0",
    "@angular/platform-browser": "4.0.0",
    "@angular/platform-browser-dynamic": "4.0.0",
    "@ionic-native/barcode-scanner": "4.4.2",
    "@ionic-native/base64": "^4.17.0",
    "@ionic-native/battery-status": "4.15.0",
    "@ionic-native/camera": "4.13.0",
    "@ionic-native/core": "4.1.0",
    "@ionic-native/email-composer": "^5.0.0",
    "@ionic-native/file": "4.14.0",
    "@ionic-native/file-chooser": "^4.17.0",
    "@ionic-native/file-opener": "^4.17.0",
    "@ionic-native/file-path": "4.1.0",
    "@ionic-native/file-transfer": "^4.13.0",
    "@ionic-native/geolocation": "4.4.2",
    "@ionic-native/http": "^4.20.0",
    "@ionic-native/keyboard": "3.4.4",
    "@ionic-native/media": "4.14.0",
    "@ionic-native/media-capture": "4.14.0",
    "@ionic-native/network": "4.3.2",
    "@ionic-native/phonegap-local-notification": "^4.20.0",
    "@ionic-native/push": "^4.6.0",
    "@ionic-native/splash-screen": "3.4.4",
    "@ionic-native/status-bar": "3.4.4",
    "@ionic-native/transfer": "3.14.0",
    "@ionic-native/video-capture-plus": "4.13.0",
    "@ionic-native/video-player": "4.14.0",
    "@ionic/cloud-angular": "0.12.0",
    "@ionic/storage": "2.0.1",
    "@types/cordova-plugin-battery-status": "1.2.3",
    "@types/cordova-plugin-media": "3.0.0",
    "@types/ionic": "3.19.0",
    "@types/underscore": "1.8.9",
    "angular2-signaturepad": "2.6.1",
    "babel-runtime": "6.26.0",
    "backo2": "1.0.2",
    "com-badrit-base64": "^0.2.0",
    "com.moust.cordova.videoplayer": "https://github.com/moust/cordova-plugin-videoplayer.git",
    "component-bind": "1.0.0",
    "cordova": "^8.1.2",
    "cordova-android": "^7.1.0",
    "cordova-android-support-gradle-release": "^3.0.1",
    "cordova-plugin-advanced-http": "^2.0.6",
    "cordova-plugin-battery-status": "^2.0.2",
    "cordova-plugin-camera": "^2.4.1",
    "cordova-plugin-compat": "^1.2.0",
    "cordova-plugin-device": "^1.1.7",
    "cordova-plugin-file": "^4.3.3",
    "cordova-plugin-file-opener2": "^2.2.0",
    "cordova-plugin-file-transfer": "^1.7.1",
    "cordova-plugin-filechooser": "^1.2.0",
    "cordova-plugin-geolocation": "^2.4.3",
    "cordova-plugin-ionic-webview": "^1.2.1",
    "cordova-plugin-media": "^5.0.2",
    "cordova-plugin-media-capture": "^1.4.3",
    "cordova-plugin-splashscreen": "^4.1.0",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-video-capture-plus": "1.0.0",
    "cordova-plugin-video-player": "git+https://github.com/moust/cordova-plugin-videoplayer.git",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-plugin-wkwebview-engine": "git+https://github.com/driftyco/cordova-plugin-wkwebview-engine.git",
    "cordova-sqlite-storage": "^2.6.0",
    "engine.io-client": "3.1.4",
    "express": "^4.16.4",
    "font-awesome": "4.7.0",
    "has-binary": "0.1.7",
    "infinite-scroll": "^3.0.6",
    "ionic": "^4.3.1",
    "ionic-angular": "3.0.1",
    "ionic-image-loader": "4.1.1",
    "ionic-img-viewer": "1.3.4",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "isobject": "3.0.1",
    "jquery": "3.2.1",
    "lodash": "4.17.4",
    "moment": "2.22.2",
    "moment-timezone": "0.5.13",
    "ng-socket-io": "^0.2.4",
    "npm-push": "^0.4.8",
    "parseuri": "0.0.5",
    "phonegap-plugin-barcodescanner": "^7.1.2",
    "phonegap-plugin-local-notification": "1.0.1",
    "phonegap-plugin-push": "^1.11.1",
    "reflect-metadata": "0.1.10",
    "rxjs": "5.1.1",
    "setimmediate": "1.0.5",
    "signature_pad": "2.3.2",
    "socket.io": "^2.2.0",
    "socket.io-client": "1.7.3",
    "socket.io-parser": "3.1.2",
    "sw-toolbox": "3.4.0",
    "to-array": "0.1.4",
    "underscore": "1.9.1",
    "zone.js": "0.8.4"
  },
  "devDependencies": {
    "@angular/tsc-wrapped": "4.4.6",
    "@ionic/app-scripts": "1.3.0",
    "@ionic/cli-plugin-cordova": "1.6.2",
    "@ionic/cli-plugin-ionic-angular": "1.4.1",
    "@types/lodash": "4.14.62",
    "@types/moment-timezone": "0.2.34",
    "@types/socket.io-client": "1.4.29",
    "typescript": "2.2.1"
  },
  "cordova": {
    "platforms": [
      "android"
    ],
    "plugins": {
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-wkwebview-engine": {},
      "cordova-sqlite-storage": {},
      "ionic-plugin-keyboard": {},
      "phonegap-plugin-push": {
        "SENDER_ID": "694054568313"
      },
      "cordova-plugin-media-capture": {},
      "phonegap-plugin-barcodescanner": {
        "CAMERA_USAGE_DESCRIPTION": " ",
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      },
      "cordova-plugin-file-transfer": {},
      "cordova-plugin-geolocation": {
        "GEOLOCATION_USAGE_DESCRIPTION": "To locate you"
      },
      "com.moust.cordova.videoplayer": {},
      "cordova-plugin-camera": {},
      "cordova-plugin-media": {},
      "cordova-plugin-file": {},
      "cordova-plugin-battery-status": {},
      "cordova-plugin-compat": {},
      "cordova-plugin-file-opener2": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      },
      "cordova-plugin-advanced-http": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-filechooser": {},
      "com-badrit-base64": {},
      "phonegap-plugin-local-notification": {},
      "cordova-android-support-gradle-release": {
        "ANDROID_SUPPORT_VERSION": "27.+"
      }
    }
  }
}

0 个答案:

没有答案