javanano protobuf的j2obj翻译无法编译

时间:2016-04-05 17:02:34

标签: protocol-buffers j2objc j2objc-gradle

我对Android和j2objc比较陌生,希望这个问题有一个简单的解决方法。 我创建了一个简单的项目来测试Android中的protobuf nano并转换为目标c。该应用程序运行良好,Java将消息发送到C#Web服务,但目标c中已翻译的javanano类的编译失败,并出现以下错误:

plugins {
    id 'java'
    id "com.github.j2objccontrib.j2objcgradle" version "0.6.0-alpha"
    id "com.google.protobuf" version "0.7.5"
}

sourceSets {
    main.java.srcDirs += 'src/main/javanano'
}

dependencies {
    // Any libraries you depend on, like Guava or JUnit
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.guava:guava:19.0'
    compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-5'
    testCompile 'junit:junit:4.12'
}

protobuf {
    protoc {
        artifact = "com.google.protobuf:protoc:3.0.0-beta-2"
    }

    generateProtoTasks {
        all().each { task ->
            task.builtins {
                remove java
                javanano {
                    option 'java_multiple_files=true'
                    option 'ignore_services=true'
                }
            }
        }
    }
    generatedFilesBaseDir = "$projectDir/src"
}

// Plugin settings; put these at the bottom of the file.
j2objcConfig {
    // Sets up libraries you depend on
    autoConfigureDeps true
//    testMinExpectedTests 0

    // Omit these two lines if you don't configure your Xcode project with CocoaPods
//    xcodeProjectDir '/Users/gabrielchoza/SoftwareDev/NGCalDev/AuthTouchId'  //  suggested directory name
//    xcodeTargetsIos 'IOS-APP', 'IOS-APPTests'  // replace with your iOS targets

    finalConfigure()          // Must be last call to configuration
}

这是build.gradle文件:

syntax = "proto3";
option csharp_namespace = "messages";
option java_package = "messages";

message Req {
    string client_version = 1;
    string client_practice = 2;
    string instance_id = 3;
}

这是其中一张照片文件:

{{1}}

我们使用的是最新版本的Xcode:版本7.3(7D175)和OS X El Capitan版本10.11.4

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

您希望升级到J2ObjC的最新版本1.0.2,因为其J2ObjC_header.h不再使用__weak属性。此较新版本对Gradle配置的更改为described here