dragon66 / icafe

Java library for reading, writing, converting and manipulating images and metadata
Eclipse Public License 1.0
203 stars 58 forks source link

ClassNotFoundException: Didn't find class "java.beans.Introspector" #95

Closed painld6 closed 3 years ago

painld6 commented 3 years ago

我下载了 libs 中所有的 jar 包,在 Android 项目中添加对应的依赖,并按照 wiki 中提及的测试代码去获取图片中的信息,但运行的时候就报出这个 NoClassDefFoundError I downloaded all the jar packages in libs, added the corresponding dependencies to the Android project, and followed the test code mentioned in the wiki to get the information in the picture, but this NoClassDefFoundError was reported when I ran it.


class CameraActivity : AppCompatActivity() {
   override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        val inputStream = assets.open("test.jpg")
        val metadataMap = Metadata.readMetadata(inputStream)
        for (entry in metadataMap) {
            if (entry.value is XMP) {
                val iterator = entry.value.iterator()

                while (iterator.hasNext()) {
                    val item = iterator.next()
                    printMetadata(item, "", " ")
                }
            }
        }
    }

    private fun printMetadata(
        entry: MetadataEntry,
        indent: String,
        increment: String
    ) {
        var ind = indent
        log(ind + entry.key + if (entry.value.isNullOrEmpty()) "" else ": " + entry.value)
        if (entry.isMetadataEntryGroup) {
            ind += increment
            val entries = entry.metadataEntries
            for (e in entries) {
                printMetadata(e, ind, increment)
            }
        }
    }
}
dragon66 commented 3 years ago

如果你在android中使用,你需要用pixymeta-android而不是icafe。前者是abdroid版的icafe去掉了对AWT等的依赖性。Android版不支持图像操作但支持元数据获取和插入。