在为Android应用程序创建jar时,我尝试在模块中拉出一些外部jar。但是每次我尝试构建jar时都会遇到此问题。
错误:任务':mpos:compileJava'的执行失败。
编译失败;有关详细信息,请参见编译器错误输出。 错误:(9、19)错误:程序包android.app不存在 错误:(14,30)错误:找不到符号类活动
“ mpos”是我的文件名。
答案 0 :(得分:0)
您必须将JAR文件放入app/libs
,并在app/build.gradle
的依赖项部分中:
compile fileTree(dir: 'libs', include: ['*.jar'])
答案 1 :(得分:0)
您可以将jar文件放在要在模块内创建的任何目录中,例如<?php
// scr/AppBundle/Controller/BooksController.php
namespace AppBundle\Controller;
use AppBundle\Entity\Book;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
class BooksController extends Controller {
/**
* @Route("/books/author")
*/
public function authorAction()
{
return $this->render('books/author.html.twig');
}
/**
* @Route("/books/display", name = "app_book_display")
*/
public function displayAction()
{
$bk = $this->getDoctrine()
->getRepository('AppBundle:Book')
->findAll();
return $this->render('books/display.html.twig', array('data' => $bk));
}
/**
* @Route("/books/new", name = "app_book_new")
*/
public function newAction(Request $request)
{
$book = new Book();
$form = $this->createFormBuilder($book)
->add('name', TextType::class)
->add('author', TextType::class)
->add('price', TextType::class)
->add('save', SubmitType::class, array('label' => 'Submit'))
->getForm();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$book = $form->getData();
$doct = $this->getDoctrine()->getManager();
// tells Doctrine you want to save the Product
$doct->persist($book);
// executes the queries (i.e. the INSERT query)
$doct->flush();
return $this->redirectToRoute('app_book_display');
} else {
return $this->render('books/new.html.twig', array('form' => $form->createView(),
));
}
}
/**
* @Route("/books/update/{id}", name = "app_book_update")
*/
public function updateAction($id, Request $request)
{
$doct = $this->getDoctrine()->getManager();
$bk = $doct->getRepository('AppBundle:Book')->find($id);
if (!$bk) {
throw $this->createNotFoundException(
'No book found for id '.$id
);
}
$form = $this->createFormBuilder($bk)
->add('name', TextType::class)
->add('author', TextType::class)
->add('price', TextType::class)
->add('save', SubmitType::class, array('label' => 'Submit'))
->getForm();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$book = $form->getData();
$doct = $this->getDoctrine()->getManager();
// tells Doctrine you want to save the Product
$doct->persist($book);
// executes the queries (i.e. the INSERT query)
$doct->flush();
return $this->redirectToRoute('app_book_display');
} else {
return $this->render('books/new.html.twig', array(
'form' => $form->createView(),
));
}
}
/**
* @Route("/books/delete/{id}", name = "app_book_delete")
*/
public function deleteAction($id)
{
$doct = $this->getDoctrine()->getManager();
$bk = $doct->getRepository('AppBundle:Book')->find($id);
if (!$bk) {
throw $this->createNotFoundException('No Book found for id '.$id);
}
$doct->remove($bk);
$doct->flush();
return $this->redirectToRoute('app_book_display');
}
}
模块或app
模块
然后在该模块的build.gradle文件中添加一个实现命令,并指定创建的jar目录。像这样
library
或者也许
implementation fileTree(include: ['*.jar'], dir: 'libs')