2017-07-06 53 views
0

您好我目前正在使用android studio的一個android項目。我想使用Paho/Mqtt庫,但在構建時似乎遇到問題。
這些都是在的build.gradle文件錯誤:警告:忽略Paho/Mqtt的匿名內部類的InnerClasses屬性

repositories { 
    jcenter() 
    maven { 
     url "https://repo.eclipse.org/content/repositories/paho-snapshots/" 
    } 
} 

dependencies { 
    compile 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.1' 
    compile('org.eclipse.paho:org.eclipse.paho.android.service:1.1.1') { 
     exclude module: 'support-v4' 
    } 
} 

有56個差錯的相關要素,但構建仍顯示爲BUILD成功的。

Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.eclipse.paho.client.mqttv3.MqttAsyncClient$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 

和該相同消息顯示開

(org.eclipse.paho.client.mqttv3.internal.ClientComms$1 
(org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule$1) 
(org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketNetworkModule$1) 
(org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence$1) 
(org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence$2) 

這5次是在搖籃控制檯

AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} 
AGPBI: {"kind":"error","text":"(org.eclipse.paho.client.mqttv3.MqttAsyncClient$1) that doesn\u0027t come with an","sources":[{}]} 
AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} 
AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} 
AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} 
AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} 
AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} 
AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} 
AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} 
AGPBI: {"kind":"error","text":"(org.eclipse.paho.client.mqttv3.MqttAsyncClient$2) that doesn\u0027t come with an","sources":[{}]} 
AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} 
AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} 
AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} 
AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} 
AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} 
AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} 
AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} 
AGPBI: {"kind":"error","text":"(org.eclipse.paho.client.mqttv3.internal.ClientComms$1) that doesn\u0027t come with an","sources":[{}]} 
AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} 
AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} 
AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} 
AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} 
AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} 
AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} 
AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} 
AGPBI: {"kind":"error","text":"(org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModule$1) that doesn\u0027t come with an","sources":[{}]} 
AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} 
AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} 
AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} 
AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} 
AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} 
AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} 
AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} 
AGPBI: {"kind":"error","text":"(org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketNetworkModule$1) that doesn\u0027t come with an","sources":[{}]} 
AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} 
AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} 
AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} 
AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} 
AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} 
AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} 
AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} 
AGPBI: {"kind":"error","text":"(org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence$1) that doesn\u0027t come with an","sources":[{}]} 
AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} 
AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} 
AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} 
AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} 
AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} 
AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} 
AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} 
AGPBI: {"kind":"error","text":"(org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence$2) that doesn\u0027t come with an","sources":[{}]} 
AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} 
AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} 
AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} 
AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} 
AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} 
AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} 

我試圖通過在我的proguard的加入修復此錯誤的日誌-rules.pro文件

-keepattributes InnerClasses 
-keepattributes EnclosingMethod 
-dontoptimize 

除了在defaultConfig塊這些線路的build.gradle文件

compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_7 
     targetCompatibility JavaVersion.VERSION_1_7 
} 

兩個以上的解決方案仍然給我留下了相同的56個錯誤。有人會知道在這種情況下要做什麼嗎?

回答

0

這可能不是最佳答案,但是我將版本更改爲1.1.2-SNAPSHOT並且構建實際上是成功的。我會看看我是否遇到任何其他錯誤。讓我知道這個解決方案是否適合你。

dependencies { 
    compile 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.2-SNAPSHOT' 
    compile('org.eclipse.paho:org.eclipse.paho.android.service:1.1.2-SNAPSHOT') { 
     exclude module: 'support-v4' 
    } 
}