Приложение работает на подключенном реальном устройстве, но не на APK - PullRequest
0 голосов
/ 12 июля 2020

На подключенном реальном устройстве работает следующий макет:

Но при запуске на встроенном apk показывает следующее:

Я не могу понять проблему, так как при запуске приложения на реальном устройстве не отображается никаких ошибок или предупреждений. Есть ли способ отладить APK?

Если я закомментирую Gridview.builder, apk будет работать так же, как и на реальном устройстве.

Это код, который я реализовал:

  Container myArticles(String imageVal,int index,String univid)
  {
    return Container(
      child:Align(
        alignment: Alignment.center,
        child: Card(
          child:Container(
            child: FlatButton(
              color: Colors.white,
            splashColor: Colors.white,
              child:Stack(
               children: <Widget>[
                  Image.asset(imageVal),
              Positioned(
                top: 120,
                left: 8,
                child: Center(
                    child:Container(
                      width: 130,
                      child: Text(widget.data[index]["subject_name"],
                      textAlign: TextAlign.center,
                      style: TextStyle(
                        fontSize: 11.0,
                        fontWeight: FontWeight.bold,
                      ),
                  ),
                    ),
                  
                ),
              ),
              Positioned(
                top: 160,
                left: 40,
                child: Center(
                  child: Text("₹"+widget.data[index]["price"],
                    style: TextStyle(
                      fontSize: 20.0,
                      color: Colors.white,
                    ),
                  ),
                ),
              ),
               ],
              ),
            onPressed: ()async {}
             },
            ),
          ),
          ),
        ),
    );
  }
  @override

  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.deepPurple,
      body: ListView(
      
      children:<Widget>[
         Column(
        children: <Widget>[
          Column(
            children: <Widget>[
              Padding(
                padding: const EdgeInsets.fromLTRB(0, 10, 100, 0),
                child: Container(
                  padding: EdgeInsets.fromLTRB(0, 30,200,0),
                  child: IconButton(icon: Icon(Icons.arrow_back,),
                    color: Colors.black,
                    onPressed: () {
                      Navigator.pop(context);
                    },
                  ),
                ),
              ),
              SizedBox(height: 20,),
              Text('Semester '+ widget.id,
                style: TextStyle(color: Colors.white,
                    fontSize: 35),
              ),
              SizedBox(height: 25,),
              Text('Subjects: '+widget.subcount,
                style: TextStyle(color: Colors.white,
                    fontSize: 17),
              ),

            ],
          ),
          SizedBox(height: 40,),
          Container(
            height: MediaQuery.of(context).size.height - 185,
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.only(topLeft: Radius.circular(75.0)),
            ),
           child: Padding(
             padding: const EdgeInsets.fromLTRB(0,100,0,50),
             child: Expanded(
                    child: GridView.builder(
                      physics: ScrollPhysics(),
                    itemCount: widget.data.length,
                    shrinkWrap: true,
                    scrollDirection: Axis.vertical,
                    gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                      crossAxisCount: 2,
                    ),
                    itemBuilder: (BuildContext context, int index){
                      return Container(
                        child: myArticles("assets/NewSub/1.png",index,widget.data[index]["univ_spec_sub_id"].toString()),
                        
                      );
                    },
                  ),
                ),
           ),
          ),
        
        ],
  ),
      ],
      ),
    );
  }
}

1 Ответ

0 голосов
/ 12 июля 2020

После сборки apk установите его на реальном android устройстве. Вы все еще можете просматривать журналы приложений. Надеясь, что у вас правильно настроены все функции adb и sdk (поскольку вы можете запускать приложение на устройстве во время сборки), выполните следующие шаги для отладки apk.

  1. Установите apk на устройство
  2. Откройте приложение
  3. Подключите устройство к вашей системе (которую вы используете для создания приложений flutter) с помощью USB.
  4. Откройте консоль
  5. Введите flutter logs
  6. Вы увидите все журналы из любого запущенного приложения flutter на вашем android устройстве.

Это не решит проблему в представлении списка, в котором не отображается проблема, но будет Позвольте вам увидеть все журналы относительно того, почему вы не можете увидеть список, а затем из журналов вы выясните, в чем заключается ошибка.

...