2015-05-25 12 views
7

Sto cercando di eseguire codice Android su VM in AWS. Ho compilato Android dalla fonte e quando sto cercando di caricare una libreria in modo esplicito (utilizzando System.load) in Dalvik VM vedo registro seguente:Dalvik compilato automaticamente non carica le librerie condivise

android_update_LD_LIBRARY_PATH not found; .so dependencies will not work! 

classe che genera questo errore:

public class Server { 
    private static final int port = 8080; 

    public static void main(String[] args) throws Exception { 
     System.load("libandroid_runtime.so"); 
     WebServer webServer = new WebServer(port); 

     XmlRpcServer xmlRpcServer = webServer.getXmlRpcServer(); 

     PropertyHandlerMapping phm = new PropertyHandlerMapping(); 
     phm.addHandler("ImgCat", ImgCat.class); 
     xmlRpcServer.setHandlerMapping(phm); 

     XmlRpcServerConfigImpl serverConfig = 
      (XmlRpcServerConfigImpl) xmlRpcServer.getConfig(); 
     serverConfig.setEnabledForExtensions(true); 
     serverConfig.setContentLengthOptional(false); 

     webServer.start(); 
    } 
    } 

script che uso per eseguire programmi in dalvikvm:

#!/bin/sh 
base=/opt/android 
root=$base/out/host/linux-x86 
export ANDROID_ROOT=$root 
bootpath=$root/framework 
export BOOTCLASSPATH=$bootpath/core.jar:$bootpath/ext.jar:$bootpath /framework.jar:$bootpath/android.policy.jar:$bootpath/services.jar 
export LD_LIBRARY_PATH=$root/lib:$LD_LIBRARY_PATH 
export ANDROID_DATA=/tmp/dalvik_$USER 
mkdir -p $ANDROID_DATA/dalvik-cache 
echo $LD_LIBRARY_PATH 
exec dalvikvm [email protected] 

dalvikvm è eseguibile da/out/host/linux-x86, non bersaglio. Penso che potrebbe essere un problema, ma dalvikvm di destinazione non è eseguibile (comando file). Ho trovato da qualche parte che compilare Android con sim target mi darà quello di cui ho bisogno, ma non sono riuscito a trovare un ramo dove è presente il target sim.

Avete qualche idea su come risolvere il problema con il caricamento delle librerie condivise? O forse sai quale ramo Android ha il sim target nel comando lunch?

Edit:

più Una cosa che ho scoperto è che se corro la mia app utilizzando WithFramework carica alcune librerie e poi va in segfault.

Edit2:

ho notato che non vi può essere un problema con libdl e libc. Libc dipende da libdl che cosa è diffrent rispetto al mio host linux. Ho controllato con il comando readelf:

readelf -d /home/ubuntu/android-x86/out/target/product/generic_x86/system/lib/libc.so 

Dynamic section at offset 0x72c54 contains 21 entries: 
    Tag  Type       Name/Value 
0x00000001 (NEEDED)      Shared library: [libdl.so] 
0x0000000e (SONAME)      Library soname: [libc.so] 
0x00000019 (INIT_ARRAY)     0x727dc 

libdl non dipende da nulla:

readelf -d /home/ubuntu/android-x86/out/target/product/generic_x86/system/lib/libdl.so 

Dynamic section at offset 0x658 contains 19 entries: 
    Tag  Type       Name/Value 
0x0000000e (SONAME)      Library soname: [libdl.so] 
0x00000019 (INIT_ARRAY)     0x1640 

ma ci sono alcuni simboli non definiti:

nm -D /home/ubuntu/android-x86/out/target/product/generic_x86/system/lib/libdl.so 
0000164c T __FINI_ARRAY__ 
00001640 T __INIT_ARRAY__ 
0000173c A __bss_start 
     U __cxa_atexit 
     U __cxa_finalize 
     w __deregister_frame_info_bases 
     w __register_frame_info_bases 
     U __stack_chk_fail 
0000173c A _edata 
00001758 A _end 
00000520 T dl_iterate_phdr 
00000500 T dladdr 
00000510 T dlclose 
000004e0 T dlerror 
000004d0 T dlopen 
000004f0 T dlsym 

Qualsiasi idea di come risolvere il problema? (Devo aggiustarlo?)

risposta

0

Ho trovato la posizione in dalvik vm da dove viene generato questo errore. È simile al seguente:

 if (javaLdLibraryPath != NULL) { 
    ScopedUtfChars ldLibraryPath(env, javaLdLibraryPath); 
    if (ldLibraryPath.c_str() == NULL) { 
     return NULL; 
    } 
    void* sym = dlsym(RTLD_DEFAULT, "android_update_LD_LIBRARY_PATH"); 
    if (sym != NULL) { 
     typedef void (*Fn)(const char*); 
     Fn android_update_LD_LIBRARY_PATH = reinterpret_cast<Fn>(sym); 
     (*android_update_LD_LIBRARY_PATH)(ldLibraryPath.c_str()); 
    } else { 
     LOG(ERROR) << "android_update_LD_LIBRARY_PATH not found; .so dependencies will not work!"; 
    } 
    } 

Sembra che se sym == null, si ottiene il messaggio di errore.

Quindi mi chiedo se la riga precedente (vedere il prossimo snipper di codice) indica semplicemente che il tuo android_update_LD_LIBRARY_PATH è inizializzato in modo errato.

void* sym = dlsym(RTLD_DEFAULT, "android_update_LD_LIBRARY_PATH"); 

Questo aiuto?

ha trovato il codice a: original source

Problemi correlati