夜空泪 2016-07-13 09:22 采纳率: 60%
浏览 2209

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条回答 默认 最新

  • 捻秋成哥 2016-07-13 09:38
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制