/Users/leili/Documents/idea_workspace/BeQuietLee/DynamicAPK/demo2/res/layout/demo2_activity_main.xml:40: error: Error: No resource found that matches the given name (at 'src' with value '@drawable/sample').
ResourceTable::ResourceTable(Bundle* bundle, const String16& assetsPackage, ResourceTable::PackageType type) : mAssetsPackage(assetsPackage) , mPackageType(type) , mTypeIdOffset(0) , mNumLocal(0) , mBundle(bundle) { ssize_t packageId = -1; switch (mPackageType) { case App: case AppFeature: packageId = 0x7f; break; case System: packageId = 0x01; break; case SharedLibrary: packageId = 0x00; break; // case Voice: // packageId = 0x34; // break; // case Call: // packageId = 0x35; // break; // case Search: // packageId = 0x36; // break; // case Schedule: // packageId = 0x37; // break; // case Train: // packageId = 0x38; // break; // case Destination: // packageId = 0x44; // break; // case Chat: // packageId = 0x46; // break; // case Flight: // packageId = 0x52; // break; // case MyCtrip: // packageId = 0x54; // break; // case Pay: // packageId = 0x55; // break; // case Foundation: // packageId = 0x56; // break; // case Hotel: // packageId = 0x58; // break; // case Container: // packageId = 0x61; // break; // case CustomerService: // packageId = 0x62; // break; // case ThirdParty: // packageId = 0x63; // break; // case Extend1: // packageId = 0x64; // break; // case Extend2: // packageId = 0x65; // break; // case Extend3: // packageId = 0x66; // break; // case Extend4: // packageId = 0x67; // break; // case Extend5: // packageId = 0x68; // break; // case Extend6: // packageId = 0x69; // break; default: assert(0); break; } if(!bundle->getApkModule().isEmpty()){ android::String8 apkmoduleVal=bundle->getApkModule(); packageId=apkStringToInt(apkmoduleVal); } sp<Package> package = new Package(mAssetsPackage, packageId); mPackages.add(assetsPackage, package); mOrderedPackages.add(package);
// Every resource table always has one first entry, the bag attributes. const SourcePos unknown(String8("????"), 0); getType(mAssetsPackage, String16("attr"), unknown); }
这里我们演示一个更换文案的demo,将demo2里面textView预设的文案由This is sample resource:换成下图来自于宿主资源。首先需要把改好的项目进行编译,取出bundle.dex与bundle.zip(这两个文件的来源,前文已经提过)。然后把它们上传到/data/data/com.ctrip.sample/files/storage/2/version_2。上传完成后,下次启动就会加载我们修改后的dex文件,展示新的内容。