Android Studio将含有Activity的Library打包成Jar包后,为什么R文件报错

打包前的代码:

  @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.loading_dialog);
        Context context = mContextWeakRef.get();
        if (context == null) {
            return;
        }
        someAnimation = (AnimationDrawable) context.getResources().getDrawable(R.drawable.loading_dialog);
        mCusProImg = (ImageView) findViewById(R.id.cus_pro);
        Log.e("LoadingDialogView", mCusProImg + "");
        mCusProImg.setImageDrawable(someAnimation);
        initView();
        Thread t = new Thread(new UpdataThread());
        t.start();
        setCanceledOnTouchOutside(outside);
    }

打包后的代码:

  protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(layout.loading_dialog);
        Context context = (Context)this.mContextWeakRef.get();
        if(context != null) {
            this.someAnimation = (AnimationDrawable)context.getResources().getDrawable(drawable.loading_dialog);
            this.mCusProImg = (ImageView)this.findViewById(id.cus_pro);
            Log.e("LoadingDialogView", this.mCusProImg + "");
            this.mCusProImg.setImageDrawable(this.someAnimation);
            this.initView();
            Thread t = new Thread(new LoadingDialogView.UpdataThread(null));
            t.start();
            this.setCanceledOnTouchOutside(this.outside);
        }
    }

1个回答

jar中不能打入资源文件,可以试试aar

Fingualin
夜空泪 我试了arr打包,但是别人要的是可以自己编辑xml跟resource资源了文件的,不过还是谢谢你
大约 4 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问