面对在Android应用程序中集成Microsoft MIP SDK时遇到的问题。

huangapple 未分类评论44阅读模式
英文:

Facing issue Integrating microsoft MIP sdk in android App

问题

以下是翻译好的部分:

我正在尝试将 Microsoft MIP SDK 集成到 Android 应用程序中,
SDK 包含一些头文件和 .so 二进制文件,以及一个名为 aria-android-java-sdk.aar 的文件,其中一个 .so 文件使用 findClass API 来使用此 aar 文件。
我尝试将 .so 和头文件添加到构建脚本中,并将 aar 文件添加到构建脚本中,但是我遇到以下错误。

[1586235339.801 32690: 317 E/void (anonymous namespace)::InitLogManager(JNIEnv *, jclass, jobject, const std::__ndk1Initializing Aria LogManager
2020-04-07 10:25:39.826 32690-317/com.sample.mipintegration A/zygote64: java_vm_ext.cc:504] 应用程序中的 JNI 检测错误: 使用未决异常调用 JNI NewGlobalRef,异常为 java.lang.ClassNotFoundException: 在路径上找不到类 "com.microsoft.applications.telemetry.core.InternalMgrImpl":DexPathList[[directory "."],nativeLibraryDirectories=[/system/lib64,/system/vendor/lib64,/system/lib64,/system/vendor/lib64]]
2020-04-07 10:25:39.826 32690-317/com.sample.mipintegration A/zygote64: java_vm_ext.cc:504]    at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:93)
2020-04-07 10:25:39.826 32690-317/com.sample.mipintegration A/zygote64: java_vm_ext.cc:504]    at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
2020-04-07 10:25:39.826 32690-317/com.sample.mipintegration A/zygote64: java_vm_ext.cc:504]    at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)

有没有一种通过 CMake 在 Android Studio 中添加依赖的 .so 文件的方法?
谢谢。

英文:

I am trying to integrate microsoft MIP sdk in Android App ,
SDK has some header files and .so bin files along with that sdk has provided aria-android-java-sdk.aar file which is being used by one of the .so files using findClass API .
I am tried adding .so and header files and added aar file into build script but i am seeing below error .

  [     1586235339.801 32690: 317 E/void (anonymous namespace)::InitLogManager(JNIEnv *, jclass, jobject, const std::__ndk1Initializing Aria LogManager
2020-04-07 10:25:39.826 32690-317/com.sample.mipintegration A/zygote64: java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception java.lang.ClassNotFoundException: Didn't find class "com.microsoft.applications.telemetry.core.InternalMgrImpl" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/system/lib64, /system/vendor/lib64, /system/lib64, /system/vendor/lib64]]
2020-04-07 10:25:39.826 32690-317/com.sample.mipintegration A/zygote64: java_vm_ext.cc:504]  at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:93)
2020-04-07 10:25:39.826 32690-317/com.sample.mipintegration A/zygote64: java_vm_ext.cc:504]  at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
2020-04-07 10:25:39.826 32690-317/com.sample.mipintegration A/zygote64: java_vm_ext.cc:504]  at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)

Is there some way to add .so dependent aar file in android studio using cmake
Thanks

答案1

得分: 0

如果您正在使用InformationProtection.AAR,您应该能够直接调用该函数。类似这样:

import com.microsoft.informationprotection.MipLibrary;

Func {
    MipLibrary.Init(getApplicationContext());
}

如果您需要拆分AAR文件,您需要进行类似以下的操作:

package com.microsoft.informationprotection;

import android.content.Context;

import java.lang.System;
import com.microsoft.applications.telemetry.core.InternalMgrImpl;
import com.microsoft.applications.telemetry.LogConfiguration;

public class MipLibrary {

    static {
        System.loadLibrary("mip_core");
        System.loadLibrary("mip_protection_sdk");
        System.loadLibrary("mip_upe_sdk");
    }

    synchronized static public int Init(Context context) {
        if (sMipLibrary == null)
            sMipLibrary = new MipLibrary();
        if (sLogConfiguration == null) {
            sLogConfiguration = InternalMgrImpl.getConfig();
        }
        return sMipLibrary.Init(context.getClass(), context);
    }

    native int Init(Class<?> contextClass, Context context);

    static private MipLibrary sMipLibrary;
    static private LogConfiguration sLogConfiguration;
}

在AAR中还包含了Protection SDK的JAR文件,这是必需的,因为它包含了有关MIP服务使用的根CA的信息。这个要求将会在今年晚些时候消失。

英文:

If you're using the InformationProtection.AAR, you should be able to call the function directly. Something like:

import com.microsoft.informationprotection.MipLibrary;

Func {
    MipLibrary.Init(getApplicationContext());
}

If you need to break apart the AAR you'll need to do something like this:

package com.microsoft.informationprotection;

import android.content.Context;

import java.lang.System;
import com.microsoft.applications.telemetry.core.InternalMgrImpl;
import com.microsoft.applications.telemetry.LogConfiguration;

public class MipLibrary {

    static {
        System.loadLibrary(&quot;mip_core&quot;);
        System.loadLibrary(&quot;mip_protection_sdk&quot;);
        System.loadLibrary(&quot;mip_upe_sdk&quot;);
    }

    synchronized static public int Init(Context context) {
        if (sMipLibrary == null)
            sMipLibrary = new MipLibrary();
        if (sLogConfiguration == null) {
            sLogConfiguration = InternalMgrImpl.getConfig();
        }
        return sMipLibrary.Init(context.getClass(), context);
    }

    native int Init(Class&lt;?&gt; contextClass, Context context);

    static private MipLibrary sMipLibrary;
    static private LogConfiguration sLogConfiguration;
}

There's a JAR included in the AAR for the Protection SDK that is required as it contains info about the root CA used by the MIP service. This requirement will go away later this year.

huangapple
  • 本文由 发表于 2020年4月8日 01:58:39
  • 转载请务必保留本文链接:https://java.coder-hub.com/61086414.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定