Can't print log messages from JNI with Android Studio

后端 未结 3 1237
有刺的猬
有刺的猬 2021-01-12 06:13

Error I\'m getting:

error: undefined reference to \'__android_log_print\'

I\'ve already added this line to my .cpp file:

3条回答
  •  离开以前
    2021-01-12 06:29

    I use Gradle 2.5 with Android Studio 1.4.1 and it works for me with this syntax:

    ldLibs += "log"

    The model build.gradle should be something similar:

    
    apply plugin: 'com.android.model.application'
    
        model{
            android {
                compileSdkVersion = 23
                buildToolsVersion = "23.0.1"
    
                defaultConfig.with {
                    applicationId = "com.local.some.project"
                    minSdkVersion.apiLevel = 17
                    targetSdkVersion.apiLevel = 23
                    versionCode = 1
                    versionName = "1.0"
                }
            }
    
            android.buildTypes {
                release {
                    minifyEnabled = false
                    proguardFiles += file('proguard-rules.pro')
                }
            }
    
            android.ndk {
                moduleName = "MyModel"
                ldLibs += "log"
            }
    
            compileOptions.with {
                sourceCompatibility = JavaVersion.VERSION_1_7
                targetCompatibility = JavaVersion.VERSION_1_7
            }
        }
    
        dependencies {
            compile fileTree(include: ['*.jar'], dir: 'libs')
            compile 'com.android.support:appcompat-v7:23.0.1'
            compile files('libs/some3rdParty.jar')
        }
        

提交回复
热议问题